Thursday, April 25, 2013

SharePoint Designer 2013 - SharePoint 2013 Workflow

Enabling SharePoint 2013 Workflow in SharePoint Designer 2013.

By Default, SharePoint 2013 Workflow is not available in SharePoint Designer 2013, you need to install workflow manager first, then configure it.



Steps to follow:


  1. Install Workflow Manager Client http://go.microsoft.com/fwlink/p/?LinkID=268376
  2. After installation, if you are communicating with Workflow manager via http or https you may need to change the powershell cmdlet to suite.  In my case I was using it over HTTP, so the following cmdlet worked for me.  You can have a look for "Workflow Management Site" in IIS, to get the workflowhosturi.
Register-SPWorkflowService –SPSite "http://myserver/mysitecollection" –WorkflowHostUri "http://myserver:12291" –AllowOAuthHttp

After those steps, you should now have the SharePoint 2013 Workflow enabled.

To see more detail, have a look at this technet article. http://technet.microsoft.com/en-us/library/jj658588.aspx#section4

Wednesday, April 3, 2013

Get fields using Javascript Client Object Model


Using the Javascript Client Object Model, you can get values from a listitem. 

How to use the JSOM is described here Code Project

Title – SP.ListItem.get_item(‘Title‘);

ID – SP.ListItem.get_id();

Url -SP.ListItem.get_item(‘urlfieldname‘).get_url()

Description – SP.ListItem.get_item(‘descriptionfieldname‘).get_description();

Current Version – SP.ListItem.get_item(“_UIVersionString“);

Lookup field – SP.ListItem.get_item(‘LookupFieldName’).get_lookupValue(); // or get_lookupID();

Created By – SP.ListItem.get_item(“Author“).get_lookupValue();

Modified by – SP.ListItem.get_item(“Editor“).get_lookupValue();

Choice Field – SP.ListItem.get_item(‘ChoiceFieldName‘);

Created Date – SP.ListItem.get_item(“Created“);

Modified Date – SP.ListItem.get_item(“Modified“); -> case sensitive does not work with ‘modified’

File  – SP.ListItem.get_file();

File Versions -  File.get_versions();.

Content Type – SP.ListItem.get_contentType();

Parent List – SP.ListItem.get_parentList();

Note:  (‘LookupFieldName’).get_lookupValue() sometimes returns an array of data, especially when your lookup allows multiple values.
In that case you will need to iterate the array and get each value individually.

 SP.ListItem.get_item(‘LookupFieldName’)[0].get_lookupValue(); - this will get the first item in the array.

For Arrays:


       for(var i = 0; i < oListItem.get_item("LookupFieldName").length; i++)
{
     alert(oListItem.get_item("LookupFieldName")[i].get_lookupId()); // or get_lookupValue()