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>"

  • If the answer was helpful could you remove it from the SO unanswered list, by marking it as answered, tnx Jun 4, 2017 at 7:53

1 Answer 1


It is all JavaScript between those &"" quotes

So with Notepad, you very carefully have to add:


 &"if(confirm('You realy want to start this Workflow?'){"



  • Thanks for the quick reply @Danny. I tried your suggestion multiple times but it does not work. maybe i'm not placing the if confirm condition in the right place. if you take a look at your old post Update #1. you add something like &"alert(url);" &"SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog',{url:url});" is it possible to use something like &"SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog',{url:url});" instead of SP.UI.Notify.addNotification('Init Workflow: '+wfName+' on item: '+itemID, false);"
    – Gene
    May 18, 2017 at 13:26
  • It is a real pain to check, but it is just JavaScript, each line wrapped in a &" " So you can create a normal JS file, execute it, make it work, then all you have to do is carefully make it a SharePoint string again. May 18, 2017 at 15:54
  • Here is a bare JS script answer: sharepoint.stackexchange.com/questions/160490/… May 18, 2017 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.