Using Javascript Object Model (JSOM) with Nintex Forms

Recently working on a project I came across an interesting scenario where I had to use Nintex form. As a part of the process the form will be querying multiple lists and displaying data on the form.

You can achieve this using the Nintex Form out of the box controls but there were specific requirements which could be achieved using the out of the box controls.

I decided to use the JSOM to complete the task and plugged in my JSOM code into Form’s custom JavaScript section. To my surprise when I ran the Nintex form nothing happened.

Quickly I figured that my code was getting executed before SharePoint finish loading all the files and required SP.js file was missing at the time of code execution.

So I tried Script on Demand to make sure that my function only gets executed after the SP.js is available.

Here is the code I have added to my Nintex form.

NWF.FormFiller.Events.RegisterAfterReady(function () {

               SP.SOD.executeFunc('sp.js', 'SP.ClientContext', myFunction);

}




function myFunction() {

.

.

.

.

}

Once I added that one line my code worked like a charm. So if you are working with Nintex forms and would like to use JavaScript Object Model then you might run into the same issue and in that case just make sure to use Script On-Demand.

SharePoint Discussion Board Quick Edit is disabled

One of the thing that you will notice that working with SharePoint Discussion Board you do not have ability to edit items using the Quick Edit. Based on my research Quick Edit option is only available when you have Standard View on your list. Since Discussion Board does not have Standard View Quick Edit option is disabled.

Doing research on this I came across this MSDN forums where the workaround was mentioned as using a PowerShell to enable Quick Edit on your Discussion Board list.

https://social.technet.microsoft.com/Forums/sharepoint/en-US/b5a74681-ba88-43e2-b406-82d25fa38b25/quick-edit-greyed-out-in-custom-list

$web = Get-SPWeb “YOUR WEB URL”
$list = $web.Lists.TryGetList(“YOUR DISCUSSION LIST”)
$list.DisableGridEditing = $false
$list.Update()

I have tried this on my development environment and it seems to be working but just word of caution, I am not sure if this method of enabling Quick Edit is supported.

So if you are using this approach I would advise you to validate if this is supported by Microsoft.

Get Site Collection properties using PowerShell – SharePoint 2013

Today I am just going to blog about how to get certain information about site collections to which SharePoint Administrators might not have access to. This question comes up quite often on SharePoint forums.

If you are looking to get information for the site collection or want to generate report on site collection properties then your best friend is Get-SPSiteAdministration cmdlet. This cmdlet contains more than one parameter set. You may only use parameters from one parameter set, and you may not combine parameters from different parameter sets.

If you want to learn how to use parameters sets then follow the link below.

https://msdn.microsoft.com/library/dd878348(VS.85).aspx

For example if you would like to list primary site collection administrator and secondary site collection administrator then you would use something like,

Get-SPSiteAdministration -identity SITECOLLECTIONURL -Limit ALL | Select -Property OwnerDisplayName, SecondaryContactDisplayName

Here is the list of all the properties that you can get using this cmdlet.

https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spsiteadministration_properties.aspx

Similar to this there is Set-SPSiteAdministration cmdlet which can be used to set different properties for the site collections.

Cannot find s4-ribbonrow in oslo master page

Today’s post is quick how to when working with SharePoint Online Master page.

When working with SharePoint Online oslo master page, you will find that usual way of hiding gear icon would not work i.e. you will not find the div for s4-ribbonrow. Seattle.master still has that.

Reason for that is because Oslo and Seattle are different master page. You can read about the difference in the following blog post.

Coming back to hiding the gear icon you can target the button ID to hide it.

Either in your CSS or Script Editor web part add the following Style.

<style>#O365_MainLink_Settings{ display:none;}</style>

Where O365_MainLink_Settings is the ID of Settings button.

I hope this helps someone.

SharePoint Saturday – New York 2016

Last week, I was at New York speaking at SharePoint Saturday NYC. It was pretty exciting to see more than 600 user attending SharePoint Saturday NYC and also gave me chance to meet many of my speaker friends. The event was at Microsoft office in New York.


I would like to thank everyone who attended my session. I presented on creating SharePoint 2016 farm on Microsoft Azure using Azure Resource Manager (ARM).

http://lanyrd.com/2016/spsnyc/sfbzpz/
It is always amazing to speak at SharePoint Saturday New York since it is one of the biggest SharePoint community event with over 500 attendees every year.

Kudos to all the organisors, sponsors and volunteers for successful event!!!

I look forward to speaking in next year’s SharePoint Saturday NYC.

PowerShell – Querying User Profile Service Application – SharePoint Server 2013

This blog is quick way to show you how you can query your user profile service application for specific user. It is always easy to find user by using the UserName but in case where you do not have username available but the display name available e.g. someone giving you excel file to load data in SharePoint list.

In that case you can use the following script to query the user profile service application using the display name.

Here is the script.

 

Add-PSSnapin microsoft.sharepoint.powershell

$site = Get-SPSite "http://intranet.contoso.com/"

$web = $site.OpenWeb();

$context = Get-SPServiceContext $site;

$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context);   

$searchPattern = “USER DISPLAY NAME”;   

$searchResults = $profileManager.Search($searchPattern);

foreach($result in $searchResults)
{
    write-host $result.AccountName;
}