I want to add a button to a form to make it easier for users to launch a
particular workflow rule.
Can anyone suggest some sample code for the isv file ?
Thanks
Ian
Ian
"Philippe" <Phil...@discussions.microsoft.com> wrote in message
news:655251D6-65A0-46D2...@microsoft.com...
> I've got the same question here, because some users find the whole menu
> with
> workflows and click to start it to difficult... :-)
--
if it all works without errors then where is the challange?
My example runs the workflow against a custom entity.
The workflow process ID is specified at the top of the .js file.
The workflow is run for each selected instance of the custom entity.
A window is opened we then workflow starts letting the user know that a
workflow is in progress and then closed when it is finished. This is optional.
As my workflow sets the instances to inactive once the workflow hasa been
run against it, I have to refresh the page (last line of .js file).
Hopes this helps people
From isv.config.xml
<Entity name="ditr_skeletonapplication">
<Grid>
<MenuBar>
<Buttons>
<Button Title="Create Application" ToolTip="Create an
Application(s) from selected a Skeleton Application(s)"
Icon="/_imgs/ico/18_addSelectionRule.gif" PassParams="1"
JavaScript="
var x=new ActiveXObject('Msxml2.XMLHTTP');
x.open('GET','/UserDefined/workflow.js',false);
x.send('');
eval(x.responseText);
"
/>
</Buttons>
</MenuBar>
</Grid>
</Entity>
From /UserDefined/workflow.js:
win = window.open("/UserDefined/CustomPages/ApplyRule1.htm", "Workflow",
"top=300,left=400,height=200,width=250,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no");
var workFlowPrcoessID = "6b5c5b93-d579-4421-9b5e-9ea8ea010387";
var skelAppID;
var a = document.all["crmGrid"].InnerGrid.SelectedRecords;
if (a.length > 0)
{
var backCompatArray = new Array(a.length);
for (var i=0; i < a.length; i++)
{
skelAppID = a[i][0];
var xml = "" +
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
" <soap:Body>" +
" <Request xsi:type=\"ExecuteWFProcessRequest\"
xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" +
" <ProcessId>" + workFlowPrcoessID + "</ProcessId>" +
" <EntityMoniker>" +
" <Id xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\">"
+ skelAppID + "</Id>" +
" <Name
xmlns=\"http://schemas.microsoft.com/crm/2006/CoreTypes\">ditr_skeletonapplication</Name>" +
" </EntityMoniker>" +
" </Request>" +
" </soap:Body>" +
"</soap:Envelope>" +
"";
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/Execute");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var resultXml = xmlHttpRequest.responseXML;
}
}
win.close();
window.location.reload();