can't access the sysID of the record where ui action was trigger in the following ui page processing script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 08:36 AM
Hi Community,
I'm at my wit's end here. I built a ui action and a ui page in a custom application. The UI action is successfully calling the UI page and the client script is processing and displaying the alert I configured. I have not been able to successfully pass the sysID of the record from which the UI action was initially launched into the processing script to trigger all of the server side changes that I would like to make.
I feel like i've looked everywhere and tried everything at this point and am totally stumped, some links to content I looked at are below.
- https://www.servicenowelite.com/blog/2014/2/24/copy-incident
- https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/concept/c...
- https://community.servicenow.com/community?id=community_question&sys_id=6612ec53db76abc0656a5583ca96...
And here is the code for both elements
UI Action
client box is checked and onlick is set to conversionType() )
function conversionType()
{
var custom_record_id = g_form.getUniqueValue().value;
var gdw = new GlideDialogWindow("x_custom_application_table");
gdw.setTitle("Select Option");
gdw.setSize(750,300);
gdw.setPreference("CustomRecordID", custom_record_id);
gdw.render();
}
UI Page
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:evaluate var="jvar_customRecordID" expression="RP.getWindowProperties().get('customRecordID')" />
<g:ui_form id="phased"><h1>Select the correct gate conversion option and click ok to proceed.</h1>
<p>${jvar_customRecordID} - This value is always null</p>
<input type="hidden" id="recordsSysID" name="recordsSysID" value="jvar_customRecordID"/>
<input type="radio" id="1" name="phased" value="true"> A phase of this project has been completed </input><br/>
<input type="radio" id="2" name="phased" value="false"> Entire Project Has Been Completed </input><br/><br/>
<button type="submit" onclick="validateForm();"> Continue </button>
</g:ui_form>
</j:jelly>
Client Script
function validateForm() {
var id = g_form.getUniqueValue(); // this works and returns the sysID of the originating record.
GlideDialogWindow.get().destroy();//Close the dialog window
alert(" Client Script triggered! ID of parent record is " + id ); // this works but I can't figure out how to send this value to the processing script
}
Processing Script
gs.info('DEBUG >> Comm-test this works');
var gr = new GlideRecord('x_custom_application_table');
gr.info('Glide opened this also works');
gr.get(recordsSysID); // can't find a way to pull the unique id from the client script so trying and failing to pull it from the html
gr.info('Gate number:' + gateSysID); //This always fails to retrieve any value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 08:41 AM
Hi,
can you change your code as below and test once; no need to give .value()
var custom_record_id = g_form.getUniqueValue();
also check you are not sending the name correctly; send customRecordID and get the same in ui page
gdw.setPreference("customRecordID", custom_record_id);
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 10:14 AM
I can see that UI action has "CustomRecordID" with C in caps
gdw.setPreference("CustomRecordID", custom_record_id);
Where as UI page has c in lower case
<g:evaluate var="jvar_customRecordID" expression="RP.getWindowProperties().get('customRecordID')" />
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 11:37 AM
Thanks for your responses. I tried both of your suggestions and it appears neither my processing script or the html are able to access and store the sysid of the original ticket. I included the screenshots below to show the issue.
UI Action Code
function conversionType()
{
var custom_record_id = g_form.getUniqueValue();
var gdw = new GlideDialogWindow("x_custom_application_table");
gdw.setTitle("Select Option");
gdw.setSize(750,300);
gdw.setPreference("customRecordID", custom_record_id);
gdw.render();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 11:59 AM
Try UI action with below script
function conversionType()
{
var custom_record_id = g_form.getUniqueValue().value;
var gdw = new GlideDialogWindow("x_custom_application_table");
gdw.setTitle("Select Option");
gdw.setSize(750,300);
gdw.setPreference("customRecordID", g_form.getValue('custom_record_id'));
gdw.render();
}