Posts

Showing posts with the label SharePoint Online

SharePoint Online: How do I run a Javascript update with a lookup on a NewForm.aspx or EditForm.aspx?

The requirement I faced with my SharePoint online project was to update fields on the new and edit forms once an item had been selected. The main problem was that the update required a lookup to existing data for each item in a multi select box. The obvious solution was to use  PreSaveAction  in a Script Editor webpart, The script looked something like this: <script type="text/javascript" src="//code.jquery.com/jquery-1.11.2.min.js"></script>          <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.min.js"></script> <script type="text/javascript"> var $j = jQuery.noConflict();  function PreSaveAction() {  function SetValue(onComplete) { // clear the target item $("textarea[id*='MyTargetField']").val(''); var listTitle = 'MyLookupList'; var ids = [];                 // get the items fr

SharePoint: How can I improve the search relevance of a list item? (How do I use RecordPageClick?)

In order to improve the relevance of a list item, I learnt about RecordClick . Thankfully, I found the following code on Technet  to resolve the problem. I have duplicated it here. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Security; using System.Threading.Tasks; using Microsoft.SharePoint.Client; using Microsoft.SharePoint.Client.Search; using Microsoft.SharePoint.Client.Search.Query; using System.IO; namespace SPOnlinePageCallback2 {     class Program     {         static void Main(string[] args)         {             using (ClientContext clientContext = new ClientContext("https://xxxxxxx.sharepoint.com/"))             {                 SecureString passWord = new SecureString();                 foreach (char c in "XXXXXXXX".ToCharArray()) passWord.AppendChar(c);                 clientContext.Credentials = new SharePointOnlineCredentials("xxxxxx@xxxxxx.onmicrosoft.com", pas

SharePoint Online: How do I extract list changes with PowerShell?

Import-Module 'C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell' -DisableNameChecking $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") $webUrl = "https://mysite.sharepoint.com/" $username = "richard.leeman@mydomain.onmicrosoft.com" $password = Read-Host -Prompt "Password for $username" -AsSecureString $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $web = $ctx.Web $webs = $web.Webs $lists = $web.Lists $ctx.Load($lists) $ctx.Load($webs) $ctx.Load($web) $ctx.ExecuteQuery() $list = $lists| Where-Object { $_.Title -eq "My Documents"} $dt = Get-Date $dtUTC = $dt.ToUniversalTime() $changeQ

SharePoint Online: How do I configure the Site Collection Audit Settings from CSOM?

My current project requires that the Site Collection Audit Settings be provisioned with every new OneDrive for Business site. The problem is that there is not existing API (in CSOM or PowerShell) to set these values. Problem? Yes. Insurmountable? No. I was pointed in the direction of this  fantastic blog. The basic idea behind the code is to replicate the 'POST' event that is created by using the UI. The code is magnificent but (as is continually stressed in the video) is not supported by Microsoft.  This does not mean that is will not work, it just means that should the name of the underlying fields change, the code will fail unceremoniously. Anyway, back to the solution.  Firstly, enable the 'Reporting' Site Collection feature. The feature Guid is "7094bd89-2cfe-490a-8c7e-fbace37b4a34" and should be activated as a FARM level feature Secondly, here is my add-in code to the set values. using System.Globalization; namespace Contoso.Remote

SharePoint Online: How do I set the Web.AlternateCSS property in CSOM?

The properties are only exposed in the '16' (SharePoint Online) version of the client side dlls. You will need to change your references to point to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll and C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll

SharePoint Online: How do I brand my Sites, Subsites and OneDrive for Business Site?

The patterns for applying branding during site creation have changed, but fortunately, the Patterns and Practices team have provided some excellent guidance on how to resolve some common issues. Here are some of the links I have found very useful: Async site collection creation: https://github.com/OfficeDev/PnP/tree/master/Samples/Provisioning.Cloud.Async Sub site creation app: https://github.com/OfficeDev/PnP/tree/master/Samples/Provisioning.SubSiteCreationApp OneDrive for Business: https://github.com/OfficeDev/PnP/tree/master/Solutions/Provisioning.OneDrive

SharePoint Online: How do I set the IRM settings for a Document Library in PowerShell?

I have used the CSOM approach to resolve the problem. Here  is an excellent post outlining the available methods that I based this script on. Import-Module 'C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell' -DisableNameChecking $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") $webUrl = "https://mytestsite.sharepoint.com/mysubsite" $username = "richard.leeman@mysharepointonlinelogin.com" $password = Read-Host -Prompt "Password for $username" -AsSecureString $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $web = $ctx.Web $lists = $web.Lists $ctx.Load($lists) $ctx.Load($web) $ctx.ExecuteQuery() $li