UI Page Processing Script is Not Starting

Ryan Bray1
ServiceNow Employee

Greetings,

I'm having trouble getting the processing script to engage in my instance. Basic functionality I'm looking for is a form button that pops up a window asking how many runs they'd like to execute which updates a field in the current form. Then a server side script executes. That's it!

I'm calling a UI page from a UI action. I believe the problem resides in the client script in the UI page but I can't find out where it is.

UI Action Details:

Name: Start Runs

Active enabled

Form Button enabled

Client enabled

OnClick: Onclick = numRunsDialog()

Client Script

function numRunsDialog(){

  var dialog = new GlideDialogWindow('loadsim_start_runs');

  dialog.render();

}

UI Page Details:

Name: loadsim_start_runs

Application: Global

Catagory: General

HTML:

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

      <section class="textarea_holder">

              <p>Please set number of runs to execute</p>

              <textarea rows="1" name="dialog_numRuns" id="dialog_numRuns" label="" value="" mandatory="true" class="form-control"/>

      </section>

  <br></br>

  <section class="button_holder">

  <button onclick="return validateNumRuns()">Submit</button>

  </section>

</j:jelly>

Client Script:

function validateNumRuns() {

  //Make sure there are comments to submit

  var numRuns = gel("dialog_numRuns").value;

  numRuns = trim(numRuns);

  //If less than 1, alert the user and stop submission

  if (numRuns < 1 || numRuns > 10 ) {

  alert("Please enter number of runs (max 10).");

  return false;

  }

  //If there is input, close the dialog window and submit them

  g_form.setValue("u_num_runs", numRuns); //Set the u_num_runs with value from the dialog

  g_form.save();

}

Processing Script:

gs.print('testing');

As you can see my current processing script is extremely simple (it used to be big but I trimmed it way down for debugging). I think there is an issue with the client script but I can't figure it out (have dumbed it down significantly to get to this point).

Please advise and I will give MANY UPVOTES!

Thanks,

Ryan

1 ACCEPTED SOLUTION

Ryan Bray1
ServiceNow Employee

Answering my own question here. The problem was that I was missing the <g:ui_form> tag. Apparently leaving that tag off the HTML, causes the UI page to ignore the processing script.



Here is a fixed version of the HTMl field from my UI Page (added tags in bold).



HTML:


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


  <g:ui_form>


  <section class="textarea_holder">


              <p>Please set number of runs to execute</p>


              <textarea rows="1" name="dialog_numRuns" id="dialog_numRuns" label="" value="" mandatory="true" class="form-control"/>


      </section>


      <br></br>


      <section class="button_holder">


      <button type="submit" onclick="return validateNumRuns();">Submit</button>


      <input type="text" id="hidden1" value=""></input>


      </section>


  </g:ui_form>


</j:jelly>



Hopefully this answer is useful to someone other than me!


View solution in original post

5 REPLIES 5

sachin_namjoshi
Kilo Patron

In order to use processing script you will have to do following:



1) Have a hidden input tag in your html section


<input type="text" id="hidden1" value=""></input>



2) In the client script section whichever function you call set the value of this hidden field


document.getElementById("hidden1").value = "hidden";



3) In processing script have this as first line of code


if(hidden1 != ''){


// go and do in processing script


}


Thanks Sachin. I tried this and still not working. I see the new field in the pop up but I can't get anything in the processing script to run...



My processing script now looks like this:


if(hidden1 != ''){


  gs.log("yay, processing script is running");


}



Still nothing in the system log or the debug output.


nishailame
ServiceNow Employee

This might help you.



http://wiki.servicenow.com/index.php?title=UI_Pages#gsc.tab=0




https://community.servicenow.com/thread/193505




Thanks.


PS: Hit like, Helpful, Correct and Endorse, if it answers your question.


Thanks Nisha. I saw that thread and tried everything suggested. None of the fixes worked for me.