html 此代码块使用工作流Web服务为javascript启动工作流,jquery运行soap操作
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 此代码块使用工作流Web服务为javascript启动工作流,jquery运行soap操作相关的知识,希望对你有一定的参考价值。
<script type="text/javascript" src="http://sharepoint/WorkflowTesting/SiteAssets/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
var strMessage = '<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
'<soap:Body>' +
'<StartWorkflow xmlns="http://schemas.microsoft.com/sharepoint/soap/workflow/">' +
'<item>http://sharepoint/WorkflowTesting/Lists/TestList/1_.000</item>' +
'<templateId>33075967-e203-437d-b098-028595a38068</templateId>' +
'<workflowParameters><Data></Data></workflowParameters>' +
'</StartWorkflow>' +
'</soap:Body>' +
'</soap:Envelope>'
$.ajax({
url: 'http://sharepoint/WorkflowTesting/_vti_bin/workflow.asmx',
beforeSend: function(xhr) {
xhr.setRequestHeader("SOAPAction",
"http://schemas.microsoft.com/sharepoint/soap/workflow/StartWorkflow");
},
type: "POST",
dataType: "xml",
data: strMessage,
processData: false,
contentType: "text/xml; charset=\"utf-8\"",
success: OnSuccess,
error: OnError
});
function OnError(jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
function OnSuccess(jqXHR, textStatus) {
//alert('Success!!');
alert(textStatus);
}
</script>
<script type="text/javascript" src="http://sharepoint/WorkflowTesting/SiteAssets/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(processOverdues, "sp.js"); });
function processOverdues(){
var clientContext= new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('TestList');
var camlQuery = new SP.CamlQuery();
/*camlQuery.set_viewXml(
'<View><Query><Where><Eq><FieldRef Name=\'IDKey\'/>' +
'<Value Type=\'Text\'>' + itemKey + '</Value></Eq></Where></Query>' +
'<RowLimit>55</RowLimit></View>'
);*/
//console.log(itemKey);
this.collListItem = oList.getItems(camlQuery); //oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(
function(){
var listItemEnumerator = collListItem.getEnumerator();
var i = 1;
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
itemWorkflow(oListItem.get_item('ID'))
//console.log(i);
}//end while
}
,
function(a,b){
//console.log('Request failed. ' + b.get_message() + '\n' + b.get_stackTrace());
}
);
}
function itemWorkflow(itemID){
var strMessage = '<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
'<soap:Body>' +
'<StartWorkflow xmlns="http://schemas.microsoft.com/sharepoint/soap/workflow/">' +
'<item>http://sharepoint/WorkflowTesting/Lists/TestList/' + itemID + '_.000</item>' +
'<templateId>33075967-e203-437d-b098-028595a38068</templateId>' +
'<workflowParameters><Data></Data></workflowParameters>' +
'</StartWorkflow>' +
'</soap:Body>' +
'</soap:Envelope>'
$.ajax({
url: 'http://sharepoint/WorkflowTesting/_vti_bin/workflow.asmx',
beforeSend: function(xhr) {
xhr.setRequestHeader("SOAPAction",
"http://schemas.microsoft.com/sharepoint/soap/workflow/StartWorkflow");
},
type: "POST",
dataType: "xml",
data: strMessage,
processData: false,
contentType: "text/xml; charset=\"utf-8\"",
success: OnSuccess,
error: OnError
});
}
function OnError(jqXHR, textStatus, errorThrown) {
//alert(errorThrown);
}
function OnSuccess(jqXHR, textStatus) {
//alert('Success!!');
//alert(textStatus);
}
</script>
以上是关于html 此代码块使用工作流Web服务为javascript启动工作流,jquery运行soap操作的主要内容,如果未能解决你的问题,请参考以下文章