- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2014 12:50 PM
hey all,
I have a UI page that I recenty built to accommodate mobile approvals for a custom table and I need to pass text captured from a JavaScript prompt to the comment/journal field on the sysapproval_approver record.
Below is the relevant code I have right now:
HTML/Button
<input type="button" name="comment" value="Send Back" onclick="sendback()" style="background-color:yellow"></input>
Client Script
function sendback() { var comments = prompt("Please specify what needs to change on this specific Invoice", ""); //if comments are entered in the box if (comments != ""){ alert('This Invoice has been sent back so that these adjustments can be made.') var approval = new GlideRecord('sysapproval_approver'); approval.addQuery('sys_id','=','$[jvar_approval_sysid]'); approval.addQuery('status','=','requested'); approval.query(); while(approval.next()) { approval.state = 'adjustment'; //set approval to 'adjustment' //approval.comments.setJournalEntry(); //set approval comments to note section. will be logged and emailed out to submitter //approval.setJournalEntry(comments); //approval.comments = gel('comment').value; approval.update(); //update approval var record = new GlideRecord('u_invoices'); record.addQuery('sys_id','=',approval.document_id); //find invoice record with same sysid as approval.document_id record.query(); while(record.next()){ record.update(); //update record } } } //otherwise else { alert("We need to provide a reason when we send this Invoice back to the original submitter. \n\nPlease click on the 'Send Back' button again and specify what needs to be changed."); } location.reload(); }
Everything works in the above code, with the exception of me not being able to grab the text entered in the 'prompt' and send that to the comment/journal field on the related approval.
As you can see in lines 13-15 I have a few meger attempts at passing the value back, but I just can't seem to write back to the journal.
Can anyone help?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2014 12:10 PM
I was able to create a work-around for this issue by creating a new field on the sysapprova_approver table and storing the comments in there. Not the way I'd like to do it but it technically serves the same purpose. I'm now able to store the comments and grab them for email notification as necessary.
Thank you to all that have assisted. I believe I'm 1-2 tweaks away from getting it but unfortunately need to go with the work-around for the time being.
I'll continue to work on this and update when I have some free time down the road.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2014 12:10 PM
I was able to create a work-around for this issue by creating a new field on the sysapprova_approver table and storing the comments in there. Not the way I'd like to do it but it technically serves the same purpose. I'm now able to store the comments and grab them for email notification as necessary.
Thank you to all that have assisted. I believe I'm 1-2 tweaks away from getting it but unfortunately need to go with the work-around for the time being.
I'll continue to work on this and update when I have some free time down the road.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2015 11:51 PM
Matthew, did you end up getting this working as you expected? I'm doing something similar and I prompt the user with a GlideDialogWindow, then I'd like to pass their input back to the record they were just on. It seems like this Processing script is what I need, but I'm not sure how to go about it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2015 08:55 AM
Travis,
I am suffering through the same problem. According to the WIKI it should be straightforward but seems anything but! I have a UI Page with HTML, Client Script, and Processing script. I display Dialog Box, enter the comment. Client script Alerts confirm it is there. Problem is that the Processing Script (so I am told) is supposed to "see" the HTML comment variable only it doesn't. Here is the WIKI link: http://wiki.servicenow.com/index.php?title=Displaying_a_Custom_Dialog#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2015 11:19 AM
Hey Greg,
Actually, I didn't end up using the processing script, but instead used the Client Script with the following code:
function continueOK(){
//Get the selected values from the right slushbucket
var values = slush.getValues(slush.getRightSelect());
GlideDialogWindow.get().destroy(); //Close the dialog window
g_form.setValue("recipients", values.join() );
//return true;
}
Where "continueOK" is the function in the Submit button:
<g:dialog_buttons_ok_cancel ok="return continueOK()" cancel="return continueCancel()" ok_type="button" cancel_type="button"/>
g_form is the record from which the dialog is launched, in our case from a UI Action button from an Incident.