Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

start workflow using javascript

$
0
0
function AfterSave() {
alert("in");

	var scriptbase = _spPageContextInfo.webAbsoluteUrl + "/_layouts/15/";    
	$.getScript(scriptbase + "SP.js", function () {    
		$.getScript(scriptbase + "SP.Runtime.js", function () {    
			$.getScript(scriptbase + "SP.WorkflowServices.js", function () {
				var itemId=5;
				var subscriptionId = '{8891EB88-D7F6-495B-A420-877E74754522}';
				var clientContext = SP.ClientContext.get_current();
				var web = clientContext.get_web();
				clientContext.load(web);
				var wfManager = SP.WorkflowServices.WorkflowServicesManager.newObject(clientContext, clientContext.get_web()); 
				clientContext.load(wfManager);
				alert("in2");
				var subscription = wfManager.getWorkflowSubscriptionService().getSubscription(subscriptionId);
				clientContext.load(subscription);				
				alert("in3");
				clientContext.executeQueryAsync(
					function(sender, args){
						alert("Subscription load success. Attempting to start workflow.");        
						var inputParameters;
						wfManager.getWorkflowInstanceService().startWorkflowOnListItem(subscription, itemId, inputParameters);

				clientContext.executeQueryAsync(
					function(sender, args){ alert("Successfully starting workflow."); },
					function(sender, args){ 
						alert("Failed to start workflow.");
						alert("Error: " + args.get_message() + "\n" + args.get_stackTrace());
					}
				);
				},
				function(sender,args){
					alert("Failed to load subscription.");
					alert("Error: " + args.get_message() + "\n" + args.get_stackTrace());
				}
			);
			});    
		});   
	});

 }

function closeInProgressDialog() {
   if (dlg != null) {
       dlg.close();
   }
}
 

function showInProgressDialog() {
   if (dlg == null) {
       dlg = SP.UI.ModalDialog.showWaitScreenWithNoClose("Please wait...", "Waiting for workflow...", null, null);
   }
}

hi friends

i am using above code to start workflow

there is no error in code but it is not starting.

please help me to figure out my problem


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>