Passing form values into a Processing Script

zschneider
Kilo Expert

I'd like to update the comments field for a ticket in a ui page and am having trouble figuring out how to pass the value from a textarea field int othe processing script.

In my HTML I have this:


<g:ui_form>
       <g:dialog_buttons_ok_cancel ok="return true" />
       <input type="hidden" name="incident_id" value="SYS_ID_OF_TICKET"/>
       <textarea id="comments" name="comments"></textarea>
 </g:ui_form>


My processing script has this:

var inc = new GlideRecord('incident');
inc.get(incident_id);
inc.comments  = document.getElementById('comments');
inc.work_notes = "this is a test";
inc.update();
var urlOnStack = Packages.com.glide.sys.GlideSession.get().getStack().bottom();
response.sendRedirect(urlOnStack);


document.getElementById('comments'); does not work and I'm really not sure what to put here to pull the value from the comments textarea into the processing script. If it's possible to do inc.get to an input field to query the table, you'd think there would be a way to pass other form fields into a business rule.

Does anyone have any idea?
1 ACCEPTED SOLUTION

Chris_Hann
ServiceNow Employee
ServiceNow Employee

Try the following line instead:

inc.comments = comments;

The values of each form input are available via a variable with the same name as the name attribute of input element.

Have you considered using a cut-down version of the Form (using a View), instead of a custom UI Page?


View solution in original post

6 REPLIES 6

We were able to update work_notes fields from a processing script. The user has to authenticate first though which was an issue for us at the time.


Community Alums
Not applicable

Instead of using OK and Cancel buttons, is it possible with just Submit. We need the same functionality with Submit button.



<g:dialog_buttons_ok_cancel ok="return true" />