I am trying to mock up the Workflow form (the URL is ~siteCollection/_layouts/15/CstWrkflIP.aspx?List={xxx}) with JQuery. I have included the script file within Master Page so that whenever the URL matching, the script will hide some fields and pre-fill some input, etc.

The script fired as expected at first load. But when I click on the "Add stage" button of Approval Workflow, all the mock up is gone. I guess it is because it triggered a postback and my script is not run again.

The "Add stage" button is the highlighted one:

enter image description here

I have placed this line in my script:


workflowmockup is my JQ function name.

Maybe I do it wrong. It only triggered first time page is load. When I click "Add a new stage" workflowMockUp is not triggered. How can I workaround it? I cannot modify CstWrkflIP.aspx directly.

  • Are you using MDS ?
    – JayHell
    Dec 14, 2015 at 17:24
  • @JayHell No, MDS is not enabled.
    – Mark L
    Dec 15, 2015 at 1:29
  • Can you paste the complete code?
    – Oak3
    Dec 16, 2015 at 11:58
  • I just tested this with no result, maybe you have ideas with this: document.querySelectorAll("[role='button'] > a")[0].addEventListener("click", function() { document.querySelector('#ctl00_PlaceHolderMain_XmlFormControl_V1_I1_T4').innerText += "This is a test" }); You may be stuck doing an infinite loop. Infopath is basically a front end for XML. Could be that the button basically does a post to this XML to add changes into the file before adding an additional row in the front end. I'll see if I find anything. Dec 16, 2015 at 18:44
  • If you want some code for an infinite loop I can write some for you. But it's not a clean solution. Dec 16, 2015 at 18:46

3 Answers 3


I know it's not how it's supposed to work, but try to wrap you function call in a jQuery(document).ready() call. I've ran into issue with functions not being called sometimes, especially in IE. The document ready did help, although there are better practices.

  • I have tried following: $(function() {workflowMockUp();} already. It only trigger at first page load. It don't fire when click "add stage".
    – Mark L
    Dec 14, 2015 at 9:36
  • Have you wrapped that function in a document ready wrapper as well? <script>$(document).ready(function () { workflowMockUp(); } );</script>
    – Oak3
    Dec 14, 2015 at 9:39
  • Yes, I tried and still the same.
    – Mark L
    Dec 15, 2015 at 1:34

Have you add any Jquery file or function in your code ?

I m asking because i have faced same issue.i found that share point function _spBodyOnLoadFunctionNames.push("workflowMockUp") Provides such inbuilt functionality same as the jquery. There are chances of Conflict between _spBodyOnLoadFunctionNames.push("workflowMockUp") and jQuery(document).ready().

Reference for this concept : http://www.stephanrocks.com/2011/10/05/_spbodyonloadfunctionnames-in-sharepoint-vs-jquerys-document-ready/#comment-10478


check spell first _spBodyOnLoadFunctionNames.push("workflowMockUp") these are correct or not

  • 1
    The spell is correct because the _spBodyOnLoadFunctionNames do trigger workflowMockUp first time page is load. But it doesn't fire again at postback.
    – Mark L
    Dec 14, 2015 at 1:42

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.