ttajic
6/23/2017 - 10:31 AM

Not working Web API ExecuteWorkflow

Not working Web API ExecuteWorkflow

//ExecuteWorkflow
//data: pass workflow input arguments as an object
//	var data = {"EntityId": accountId };
//successCallback: 
//	example: 
//	function (data) {
//  	var result = JSON.parse(data);
//  }
//	self.ExecuteWorkflow = function (workflowId, data, successCallback, errorCallback) {
//    	if (!errorCallback)
//	    	errorCallback = function (err) {
//	       		console.error(err);
//	       	};
//	    
//	    try {
//			
	        //Create request
	       	// request url
	       	//https://org.crm.dynamics.com/api/data/v8.2/workflows(“f0ca33cc-23fd-496f-80e1-693873a951ca”)/Microsoft.Dynamics.CRM.ExecuteWorkflow
	       	//
//
	        //Define the query to execute the action
//	        var query = "workflows(" + workflowId.replace("}", "").replace("{", "") + ")/Microsoft.Dynamics.CRM.ExecuteWorkflow";
//	 	  	 		       	
//       		var url = GetGlobalContext().getClientUrl() + "/api/data/v8.2/" + query;
//	       	
//	       	console.log('sending data...');
//	       	console.log(JSON.stringify(data));
//	       	debugger;
//	       	var result = $.ajax(
//	       		{
//	       			url: url,
//	       			type: 'POST',
//	       			contentType:'application/json', 
//	       			headers: [
//	       				{ "Accept": "application/json" }
//	       				, { "Content-Type": "application/json; charset=utf-8" }
//	       				, { "OData-MaxVersion": "4.0" }
//	       				, { "OData-Version": "4.0" }
//	       			],
//	       			data: JSON.stringify(data),
//	       			success: successCallback
//	       		});	       	
//	       	result.error(errorCallback);       	       	       
//	    } catch (e) {
//	        errorCallback(e);
//	    }
//	};