I need some help adding a modal dialog box to a java-scripts.
I found this java-scripts code that can be use to start a SP2013 workflow using a calculated column which is working fine. however, i think it will work better on my project if i can add a (YES/NO) modal dialog box to the code.
Can I add a start workflow link to a column in a list view?
Ideally, i should like to present the users with a prompt/dialog box with choices yes/No where YES will start the workflow and NO will just close the dialog box without starting the workflow.
here is the Script:
="<button style=""cursor:pointer;"" onclick=""{"
&"event.preventDefault();"
&"function startWorkflow(itemID, wfName) {"
&" function __startWorkflow() {"
&" var ctx = new SP.ClientContext.get_current(),"
&" wfsManager = SP.WorkflowServices.WorkflowServicesManager.newObject(ctx,ctx.get_web()),"
&" wfSubs = wfsManager.getWorkflowSubscriptionService().enumerateSubscriptionsByList(_spPageContextInfo.pageListId);"
&" ctx.load(wfSubs);"
&" ctx.executeQueryAsync(function () {"
&" wfsEnum = wfSubs.getEnumerator();"
&" while (wfsEnum.moveNext()) {"
&" var wfSub = wfsEnum.get_current();"
&" if (wfSub.get_name() === wfName) {"
&" wfsManager.getWorkflowInstanceService().startWorkflowOnListItem(wfSub,itemID,new Object());"
&" SP.UI.Notify.addNotification('Init Workflow: '+wfName+' on item: '+itemID, false);"
&" }}});}"
&" if (!SP.WorkflowServices) {"
&" var script = document.createElement('script');"
&" script.src = '/_layouts/15/sp.workflowservices.js';"
&" script.onload = __startWorkflow;"
&" document.head.appendChild(script);"
&" } else {__startWorkflow();}"
&"}"
&"var TR=this;while(TR.tagName!='TR'){TR=TR.parentNode}"
&"startWorkflow(TR.id.split(',')[1] , 'YOUR_WORKFLOW_TITLE_GOES_HERE');"
&"}"">Collect Signature</button>"