Tuesday, July 15, 2014

SharePoint Sample Field (Columns) Schemas

SharePoint Fields (Columns) XML is essential for every SharePoint Object Model development.

Multiple User Field

<Field
     ID="{f6377553-35fc-4166-9cc3-88fa32a5d7dd}"
     Name="WFCApprovers"
     DisplayName="WFC Approvers"
     Type="UserMulti"
     Required="FALSE"
     UserSelectionMode="PeopleOnly"
     Group="Custom">
</Field>

UserSelectionMode Options: PeopleOnly , PeopleAndGroup


User Field



<Field
     ID="{f6377553-35fc-4166-9cc3-88fa32a5d7dd}"
     Name="UserField"
     DisplayName="User Field"
     Type="User"
     Required="FALSE"
     UserSelectionMode="PeopleOnly"
     Group="Custom">
</Field>

Boolean Field



<Field
     ID="{6ed8dbbf-4726-4a63-b358-e4797149a8ba}"
     Name="Booleanfld"
     DisplayName="Boolean Feild"
     Type="Boolean"
     Required="FALSE"
     Group="Custom">
  <Default>1</Default>
</Field>

Text Field



<Field
     ID="{9253731d-2eba-48a1-8172-94e3eae4d266}"
     Name="TextField"
     DisplayName="Text Field"
     Type="Text"
     Required="FALSE"
     Group="Custom">
</Field>

Note Field



<Field
     ID="{9253731d-2eba-48a1-8172-94e3eae4d266}"
     Name="TextField"
     DisplayName="Text Field"
     Type="Note"
     Required="FALSE"
     Group="Custom">
</Field>

Number Field



<Field
     ID="{d0b93b5a-7df2-4aa8-95ce-98c89feefb8b}"
     Name="NumberField"
     DisplayName="NumberField"
     Type="Number"
     Required="FALSE"
     Group="Custom">
</Field>

Choice Field



<Field
     ID="{1af7f723-5eb6-43fc-a399-f6dde4397598}"
     Name="ChoiceField"
     DisplayName="Choice Field"
     Type="Choice"
     Required="FALSE"
     Group="Custom">
  <CHOICES>
    <CHOICE>NEW</CHOICE>
    <CHOICE>OLD</CHOICE>
  </CHOICES>
</Field>

Lookup List



<Field 
       ID="{d98ee21b-158e-49ff-b45e-86fb6df54225}"
       Name ="LookupList"
       DisplayName="Lookup List" 
       Type="Lookup" 
       List="Lists/List1"  
       ShowField="Title"
       Group="Custom" >
</Field>

Multi Lookup List



<Field 
       ID="{d98ee21b-158e-49ff-b45e-86fb6df54225}"
       Name ="LookupList"
       DisplayName="Lookup List" 
       Type="LookupMulti" 
       Mult="True" 
       List="Lists/List1"  
       ShowField="Title"
       Group="Custom" >
</Field>

Date Field



<Field
     ID="{33a66323-6665-434e-98b1-be3d3f692ac3}"
     Name="DateField"
     DisplayName="Date Field"
     Type="DateTime"
     Required="FALSE"
     Group="Custom">
</Field>

Calculated Field



<Field
     ID="{64027cf3-2e86-44df-8ae4-7c3fe56128e3}"
     Name="ConcatTitle"
     DisplayName="Concat Title"
     Type="Calculated"
     ResultType="Text"
     Required="FALSE"
     Group="Custom">
  <Formula>
    =CONCATENATE(PCode,&quot;-&quot;,Title)
  </Formula>
  <FormulaDisplayNames>
    =CONCATENATE([P Code],&quot;-&quot;,Title)
  </FormulaDisplayNames>
  <FieldRefs>
    <FieldRef Name="PCode" />
    <FieldRef Name="Title" />
  </FieldRefs>
</Field>

Tuesday, July 8, 2014

How to Add Multiple Users in Data Element in SharePoint List Scheme

This is method is also use for add multiple lookup values as well.

<ListInstance Title="List1" OnQuickLaunch="FALSE" TemplateType="100" Url="Lists/List1" Description="List1 List Instance">
    <Data>
      <Rows>
        <Row>
          <Field Name="Title">abc</Field>
          <Field Name="MultipleUser">9;#Melick Baranasooriya;#12;#One User</Field>
          <Field Name="MultipleValues">1;#One;#2;#Two</Field>
        </Row>
      </Rows>
    </Data>
  </ListInstance>

In here separator will be ;# thus we need to specify id;#value

Thursday, June 5, 2014

Working with workflow service in JavaScript (JSOM) in SharePoint 2013 / Office 365 (SharePoint Online) – Part 1 (iterate workflow deployments and subscriptions)

SharePoint 2013 provides set of JavaScript libraries that can used to manage workflows. First you need to refer sp.workflowservices.js which is available in _layouts/15/sp.workflowservices.js.
<script src="/_layouts/15/sp.workflowservices.js"></script>

Following are few examples of using the library

1. Get all Workflows deployed to current web
2. Get all workflow subscriptions attached to a list
3. Get all workflow subscriptions in current web
4. Get all workflow subscriptions for workflow definition

apart from these things you can get subscriptions by
    • enumerateSubscriptionsByEventSource
    • enumerateSubscriptionsByListAndParentContentType
    • enumerateSubscriptionsByListWithContentType

Get all Workflows deployed to current web

var context = SP.ClientContext.get_current();
var web = context.get_web();
var sMgr =new SP.WorkflowServices.WorkflowServicesManager(context, web);
var wDefs = sMgr.getWorkflowDeploymentService().enumerateDefinitions();
context.load(wDefs);

context.executeQueryAsync(
    function(){
        var e = wDefs.getEnumerator();
        while (e.moveNext()) {
            var def = e.get_current();
            alert(def.get_displayName() + " id: " + def.get_id());
        }
    },
    function(a,b){
        alert(args.get_message());
    }
);


Get all workflow subscriptions attached to a list 

For this you need to have List Guide related to relevant list.

var listGuid = "93A65752-DB60-496F-B9F5-CD864050DB39";     
var context = SP.ClientContext.get_current();
var web = context.get_web();
var sMgr =new SP.WorkflowServices.WorkflowServicesManager(context, web);
var sservice = sMgr.getWorkflowSubscriptionService();
var ssubs = sservice.enumerateSubscriptionsByList(listGuid);
context.load(ssubs);
context.executeQueryAsync(
   function(){
       var e = ssubs.getEnumerator();
         while(e.moveNext())
         {
           var c =  e.get_current();
           alert("Name :" + c.get_name() + " sID: " + c.get_id());
         };

   },
   function(){ alert("error")}
;


Get all workflow subscriptions in current web

var context = SP.ClientContext.get_current();
var web = context.get_web();
var sMgr =new SP.WorkflowServices.WorkflowServicesManager(context, web);
var sservice = sMgr.getWorkflowSubscriptionService();
var ssubs = sservice.enumerateSubscriptions();
context.load(ssubs);
context.executeQueryAsync(
    function(){
        var e = ssubs.getEnumerator();
          while(e.moveNext())
          {
            var c =  e.get_current();
            alert("Name :" + c.get_name() + " sID: " + c.get_id());
          };
 
    },
    function(){ alert("error")}
);


Get all workflow subscriptions for workflow definition

var wfdefinitionId = "c791c3cb-abcd-4022-bc06-6fcc6ca4f6bc"; 
var context = SP.ClientContext.get_current();
var web = context.get_web();
var sMgr =new SP.WorkflowServices.WorkflowServicesManager(context, web);
var sservice = sMgr.getWorkflowSubscriptionService();
var ssubs = sservice.enumerateSubscriptionsByDefinition(wfdefinitionId);
context.load(ssubs);
context.executeQueryAsync(
    function(){
        var e = ssubs.getEnumerator();
          while(e.moveNext())
          {
            var c =  e.get_current();
            alert("Name :" + c.get_name() + " sID: " + c.get_id());
          };
 
    },
    function(){ alert("error")}
);

Tuesday, June 3, 2014

How to change the SharePoint 2013 scripts to debug versions

SharePoint environment works with release mode java scripts which can not be (hardly) debug easily. if you want to load debug scripts resides on layout folder rather than release scripts you need to change the master page’s script manger tag.

Open the master page and alter the ScriptManager tag and scriptmode to debug.

image

then you can see SharePoint loads debug scripts.

image