Showing posts with label Workflow. Show all posts
Showing posts with label Workflow. Show all posts

SharePoint 2013 Workflow for Developer - Dev Saturday & UAE SharePoint (MSTC)

Sunday, September 22, 2013

We discuss SharePoint 2013 Workflow in depth from Developer Point of view first then we talk about in Details new  Architecture of SharePoint Workflow. thanks to All Community Members for Participating Especially MVP venkatanarasimha.kl  and MCTs (Fahad khan and Wasi) for Sharing their Knowledge with us. 2nd Part of Workflow Session will be online in upcoming week.  also we share some great learning resources free channel downloaded videos and learning content on sky drive and give one Pluralsight training Vouchers. hope we will keep motivating UAE community for more SharePointing.










Start workflow SharePoint 2013 programmatically

Friday, July 5, 2013


Javascript :)  
   // ---------- Start workflow ---------- 
    function StartWorkflow() { 
      var errorMessage = "An error occured when starting the workflow."; 
      var subscriptionId = "", itemId = "", redirectUrl = ""; 
 
      var urlParams = GetUrlParams(); 
      if (urlParams) { 
        //itemGuid = urlParams["ItemGuid"]; 
        itemId = urlParams["ID"]; 
        redirectUrl = urlParams["Source"]; 
        subscriptionId = urlParams["TemplateID"]; 
      } 
 
      if (subscriptionId == null || subscriptionId == ""{ 
        // Cannot load the workflow subscription without a subscriptionId, so workflow cannot be started. 
        alert(errorMessage + "  Could not find the workflow subscription id."); 
        RedirFromInitForm(redirectUrl); 
      } 
      else { 
        // Set workflow in-arguments/initiation parameters 
        var wfParams = new Object(); 
 
        // get reviewer loginname 
        var html = $("#ctl00_PlaceHolderMain_docReviewerUser_upLevelDiv"); 
        wfParams['DocReviewerLoginName'] = $("#divEntityData", html).attr("key"); 
        // get editor loginname 
        var html = $("#ctl00_PlaceHolderMain_docEditorUser_upLevelDiv"); 
        wfParams['DocEditorLoginName'] = $("#divEntityData", html).attr("key"); 
 
        // Get workflow subscription and then start the workflow 
        var context = SP.ClientContext.get_current(); 
        var wfManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, context.get_web()); 
        var wfDeployService = wfManager.getWorkflowDeploymentService(); 
        var subscriptionService = wfManager.getWorkflowSubscriptionService(); 
 
        context.load(subscriptionService); 
        context.executeQueryAsync( 
 
            function (sender, args) { // Success 
              var subscription = null; 
              // Load the workflow subscription 
              if (subscriptionId) 
                subscription = subscriptionService.getSubscription(subscriptionId); 
              if (subscription) { 
                if (itemId != null && itemId != ""{ 
                  // Start list workflow 
                  wfManager.getWorkflowInstanceService().startWorkflowOnListItem(subscription, itemId, wfParams); 
                } 
                else { 
                  // Start site workflow 
                  wfManager.getWorkflowInstanceService().startWorkflow(subscription, wfParams); 
                } 
                context.executeQueryAsync( 
                    function (sender, args) { 
                      // Success 
                      RedirFromInitForm(redirectUrl); 
                    }, 
                    function (sender, args) { 
                      // Error 
                      alert(errorMessage + "  " + args.get_message()); 
                      RedirFromInitForm(redirectUrl); 
                    } 
                ) 
              } 
              else { 
                // Failed to load the workflow subscription, so workflow cannot be started. 
                alert(errorMessage + "  Could not load the workflow subscription."); 
                RedirFromInitForm(redirectUrl); 
              } 
            }, 
            function (sender, args) { // Error 
              alert(errorMessage + "  " + args.get_message()); 
              RedirFromInitForm(redirectUrl); 
            } 
        ) 
      } 
    } 
 
    // ---------- Redirect from page ---------- 
    function RedirFromInitForm(redirectUrl) { 
      window.location = redirectUrl; 
    } 
 
    // ---------- Returns an associative array (object) of URL params ---------- 
    function GetUrlParams() { 
      var urlParams = null; 
      if (urlParams == null) { 
        urlParams = {}; 
        var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gifunction (m, key, value) { 
          urlParams[key] = decodeURIComponent(value); 
        }); 
      } 
      return urlParams; 
    } 

C#

var WSM = new WorkflowServicesManager(web);
var wfSubscriptionService = WSM .GetWorkflowSubscriptionService();
//get all workflows associated with the list
var subscriptions =  wfSubscriptionService .EnumerateSubscriptionsByList(listId);
//run all workflows associated with the list
foreach (var workflowSubscription in subscriptions)
{    
   //initiation parameters    
   var inputParameters = new Dictionary();    
   inputParameters.Add("WFProperty", "Value"); 
   WSM .GetWorkflowInstanceService().StartWorkflowOnListItem(workflowSubscription, itemId, inputParameters);
}

Reference :
http://code.msdn.microsoft.com/office/SharePoint-2013-Approval-f5ac5eb2
 

Create SharePoint 2013 Workflow Loop By Using SharePoint 2013 designer Preview

Sunday, October 7, 2012

One the Major Enhancements in SharePoint 2013 Workflows is availability  of "Loop"s is in SharePoint Actions. now loop are fully integrated in workflow actions. there is two type of loops. "Loop n Times" and Loop with conditions. this new feature is available with SharePoint 2013 Workflows  You can create directly   loop based workflow by using SharePoint designer 2013 preview with different actions. here i am showing one basic example how you can create loop in workflows by using SharePoint 2013.

before start this

Set up and configure SharePoint 2013 Workflow Manager


  • Installing and configuring workflow for SharePoint Server 2013


  • Open SPD2013 Preview Click on List & libraries>Select any existing list or Create new List.  




    Click on List Workflow button in ribbon. It will open one Popup.


    Fill Workflow Name and description and Select SharePoint 2013 Workflow form dropdown. if in case 
    you only see the SharePoint 2010 Workflow kindly check. did you Install and configure workflow in SharePoint Server 2013. because SharePoint 2013 Workflow is based on Azure workflows.




    In side the Ribbon  you will see one yellow to Add loop to your workflow.


    here i am create Initiation form Parameters for Loop Count.

     set the by default Value

    Click on Yellow spot in ribbon and select loop n timers.  set parameters. 


    Set send email Action in side the loop. 





    Add Email Address that mail to be send.

    create message for email.



    Click  Loop Yellow button in Ribbon. and select loop n Condition



    Create another Initiation form Parameters.



    Set Parameter and with loop values and set condition equal to not equal and hard code 10 value for comparison 

      Save and Publish

    Assess your Site from Browser and navigate to that list create one Item and
    click on workflow


    double Click on your created worflow.

    fill Parameters in  Initiation form and Click on Start Button
    Go back and list Workflow setting page



    Go to SharePoint Workflow History. you  will see updates that done in loop.


    check you Main Box for emails. 



    By Usama Wahab Khan
    thank you 

Enhancements in SharePoint 2013 Workflows.

Saturday, October 6, 2012




I was Deep Diving in SharePoint 2013 Workflow. Find So many new things in SP2013 like new architect. this time workflow is not running in side the SharePoint. its working with azure workflow. new important Enhancements which area really great.

  1.   finally Loop is fully integrated actions. 
  2.   new Feature called "Workflow Stages"  for SPD Preview 2013 no need to create state Machine workflow .
  3.  new Actions like "Start a Task Process","Assign a task" .
  4.  "Call Web Service" Action use data from web-service in workflow.
  5.  new Variables types like "Dictionary Type Variables" for an array.  
  6.  absence of Design View in SharePoint 2013.  
  7. Visual Studio 2012 workflow project type support;
  8. Support for creating custom actions.
  9. Based On Windows Workflow 4.0.


    New Actions in SP2013 Workflow



    Action Description
    Assign a Task Assigns a single workflow task to a user or group.
    Start a Task Process Initiates execution of a task process.
    Go to This Stage Specifies the next stage in a workflow to which flow control should be handed.
    Call HTTP Web Service Functions as a method call to a Representational State Transfer (REST) endpoint.
    Start a List Workflow Starts a list-scoped workflow.
    Start a Site Workflow Starts a site-scoped workflow.
    Build DynamicValue Creates a new variable of type DynamicValue.
    Get Property from DynamicValue Retrieves a property value from a specified variable of type DynamicValue.
    Count Items in DynamicValue Returns the number of rows in a variable of type DynamicValue.
    Trim String Removes all leading and trailing white-space characters from the current string.
    Find Substring in String Returns 1-based index of the first occurrence of one or more characters, or the first occurrence of a string, within a string.
    Replace Substring in String Returns a new string in which all occurrences of a specified character or string are replaced with another specified character or string.
    Translate Document Functions as a wrapper around the HTTP activity that calls the synchronous translation API. You must configure a Machine Translation Service Application for the SharePoint site on which you run the workflow.
    Set Workflow Status Updates workflow status as specified in message string.
    Create a Project from Current Item [Microsoft Project] Creates a Project Server project based on the current item.
    Set the current project stage status to this value [Microsoft Project] Sets the two status fields within the current stage of the project.
    Set the status field in the idea list item to this value [Microsoft Project] Updates the status field of the original SharePoint list item.
    Wait for Project Event [Microsoft Project] Pauses the current instance of the workflow to await a specified Project event: Project checked in, Project committed, Project submitted.
    Set this field in the project to this value [Microsoft Project] Sets the value for th

but i am really enjoy allot. with these new tools. on every step its feel like when you get new toy in my childhood.

Create Nintex Workflow With SharePoint2013 Publish your Artcile Link on your Facebook Wall

Monday, October 1, 2012

Nintex Workflow was really famous in moss 2007 and SharePoint 2010. In SharePoint 2013 with New App Model Nintex Workflow. you can add Nintex Workflow App to your Site Collection. 



Sign up for an Office 365 Developer Site
Sign up for a trial during the preview period.

Step by Step how to Sign Up @ Office 365 Developer Site

 Once Create Account on  Office 365 Developer Site  you will see Office 365 Admin Center page.


Go to SharePoint 

Go on SharePoint Central Administration Penal and where you can see by default one  Public  Site.

ON Left menu  select App > and Click on Purchase Apps. 


Select  Nintex Workflow form SharePoint App Store.


Go to your Public Site and Click View Site Contents form top menu 

Click on Add an App form Top Menu

Select the Nintex App 

Click on Trust It



Go Back to Site Contents. and Double Click on list called "Posts"



Click on Nintex Workflow form Ribbon on top
Select Design a workflow option form Popup start Screen
Click on Settings from Top. Mention workflow name and select start on create form start options

Find Facebook Action form Last Menu Search options. and drag and Drop to screen


Double Click on Facebook Action it will show you the Popup where you have to mention credential for facebook and email account. 


Click on Publish 


it will take few moment to validate your workflow.


Nintex will send you the email to authorized your email Address
 click on authorization link




Create a Post :)








Enjoy :)

by Usama Wahab Khan