Monday, January 30, 2017

Run Sharepoint Designer 2013 using Different Account

We no more have an option to switch the user account in Sharepoint Designer 2013. In earlier version (2010), we have a direct option in designer, where we have a user icon to bottom left of the screen. Upon clicking it, it pops up a window to change user account.
In 2013, we can run / start the designer with a different account by providing the other user credentials. The steps to follow, is as below.
  • Open Sharepoint designer Installation folder, in general it would be in below location
    C:\Program Files(x86)\Microsoft Office\Office15
  • Select the file named 'SPDESIGN.EXE', hold the Shift key and Right click on it
  • In the Context menu, click on 'Run as different user'. This opens up a Windows security window
  • Provide the credentials of the user with which you need to run it.
Now, the designer will be opened with provided User.

Or, the other option is to login to the system it self with the other account.

Reference: https://support.microsoft.com/en-in/help/2738178/you-cannot-switch-the-user-account-in-sharepoint-designer-2013

Tuesday, January 24, 2017

Picklists are more flexible now, in Salesforce

It was a difficult task for developers / admins to change a value in a Picklist in salesforce, as the values are directly stored in the records and if any formula fields are derived on picklist values, has to be changed. Similarly in the APEX / Visualforce code, if there is any logic based on picklist values, has to be changed.

Salesforce eased this burden in Spring 17 release.  Now on wards we have 2 values for a Picklist value, one is a label and other one is API name.
Basically the values stored in the back end in a record are API Names. When we try to get the value of a field, it fetches API value. From above picture, if we try to pull value for obj.Urgency__c, the result will be Urgent.

So, all our formulae fields' logic and also in the apex code, we can go with API names. And, we can change the label value at any point of time as per customer's need.

In order to display Picklist value in a visualforce page, make sure we go with OutputField only, to get picklist value label.  If we directly go by object field, it would display API name.

<apex:outputField value="{!obj.Urgency__c}"/>

 Few Points to consider for Picklist API Names:
  • For the first time when we create Picklist values, provided values will go into label and API Name
  • At any point, we are allowed to change API names too, by editing individual value.
  • We can also restrict API name updates through a setting. This blocks users from updating API names of all Picklist values in the Org.
  • To enable / disable above setting, go to Settings->Administer->Data Management->Picklist settings.
Reference, https://developer.salesforce.com/blogs/developer-relations/2017/01/keeping-picklist-integrations-safe-using-api-names.html

Sunday, January 22, 2017

Update List Items without modifing System columns in Sharepoint

Its most common we need to update few column values in backed without changing system columns like Modified By, Modified On in a Sharepoint list / document library.

In order to achieve this, we need to go with Item.SystemUpdate() instead of Item.Update() in your C# code.

In case, if its a one time activity and we need to update data in bulk, the easiest way is to go with PowerShell script. Below is the example to update a column value in a list without changing Modified On and Modified By values, using PowerShell.

 Add-PSSnapin microsoft.sharepoint.powershell  
 $web = Get-SPWeb "<<Site URL>>"  
 $list = $web.lists["<<List Name>>"]  
 #Get all items in particular list and save them to a variable.   
 #Here you can also apply your CAML query to fetch particular set of records  
 $items = $list.items  
 #Go through all list items  
 foreach($item in $items)  
 {       
      #If any conditions are required, can set them here in if clause.  
      #Update the fields as below.  
      $item["<<Field Display Name>>"] = "<<Value>>";  
      #This is the important change, using systemupdate will just set the above fields.  
      #This will not update Modified & Modified By Fields.  
      $item.SystemUpdate();  
 }  
 $web.Dispose();