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 02:08 PM
try with this
<input type="hidden" id="recordsSysID" name="recordsSysID" value="${jvar_customRecordID}"/>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 02:17 PM
still the same issue. I really think line 3 (below) not calculating the value correctly is the main problem here. I can simple use the jvar_customRecordID variable for the value field once I get the sysID passed correctly.
<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 02:36 PM
One last try from my side. Use below 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 id="phased"><h1>Select the correct conversion option and click ok to proceed.</h1>
<j2:set var="jvar_customRecordID" expression="RP.getWindowProperties().get('customRecordID')"/>
<p>This is the customRecordID - ${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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 02:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2021 10:40 AM
<input type="hidden" id="recordsSysID" name="recordsSysID" value="jvar_customRecordID"/>
Try to give $ sign in the value, value="${jvar_customRecord}"/>
Please mark it as Helpful if it answers your question.