CSOM SharePoint app 2013 External Services by Using WebProxy

Monday, July 29, 2013


To Create Call External Web Service in SharePoint 2013 App.  we need to WebProxy class to execute web Service Request in CSOM.  Let Create external Web service in SharePoint 2013  Sample App. remember SharePoint App Developer environment should configured.

  • How to: Set up an on-premises development environment for apps for SharePoint
  • How to: Set up an environment for developing apps for SharePoint on Office 365

    You can also  use Office 365 SharePoint Online.

  • Open Visual Studio and Create SharePoint 2013 Project.


    Add your Test or developer  Site URL


    Open App.Js File from solution Explorer. Cope the Following from Sample code and Paste into App.js


    To Call External URL from App you need to set Permission for that URL in you App Manifest

    Add your External Web Service  URL in Side tag in my case i am using free online sample of northwind Database which avaliable on services.odata.org domain name.

    Open your default.aspx file in App and SP.runtime.js  and Also Executed SharePOint Ready method  

    Define html Container with ID in my case i used message in js code so i defined tab with id
     and Hit F5


    Download code Link :http://code.msdn.microsoft.com/SharePoint-Call-External-83b49a85

    Related Content

     By usama wahab khan

    Received Microsoft Certified Trainer WelCome kit

    Friday, July 26, 2013

    Thanks to Microsoft Certified Trainer Team for Welcome MCT Welcome kit.






    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