Passing sys_id from UI Action to UI Page to Script Include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2024 12:36 PM - edited ‎09-24-2024 05:58 AM
Hello. I am creating a UI action and UI page to allow users to make updates to records. Upon entering the requested information, the UI page client script captures the information entered, sends it to script include that updates the record. I am attempting to capture the sys_id of the record that is calling the UI action/ui page, etc to pass it to the script include so I can do a glidequery on the table and update the comments on that specific record. Here are the lines of code I am using to achieve this:
This is the line in the UI Action to pass the sys_id to the UI page:
gm.setPreference('current', g_form.getUniqueValue());
<j:set var= "jvar_current" value= "${current}"/>
var recordSysId = RP.getWindowProperties().currentRec;
<input type="hidden" name="currentRec" value="${jvar_current}" id="currentRec" />
var iscpRecord = document.getElementsByName('currentRec');
//I also tried:
var iscpRecord = gel('currenRec');
//Line in the GLideAjax call.
ga.addParam('sysparm_record', iscpRecord);
//Call the variable in the script include
const record = this.getParameter('sysparm_record').split(',');
//Use the variable to look up the record and update the comments:
new global.GlideQuery('x_snc_authorizatio_table_name')
.where('sys_id', 'IN', record)
.update({
comments: allEnteredData
});
.where('sys_id', record)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2024 12:49 PM
Hi,
Sorry, your post was a bit confusing as you had a lot of content and it wasn't clear where your question was actually at, perhaps consider bolding it or highlighting it to help us? Otherwise, not everyone is going to read line-by-line of all this text initially. We want to see if we can help, firstly.
Anyways, in your script include have you checked the value of "record" to see what you're getting? Why are you splitting on it if it's just a record sys_id? Also, I would recommend reviewing your usage of GlideQuery to ensure you're using it correctly, otherwise, stick with GlideRecord?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2024 06:03 AM
Sure, the question has be formatted for bold.
As for testing what was being passed to record, yes, as stated. In an earlier similar task, with multiple sys_ids, .split was used to separate them. I simply used here as well as a test as the sys_id was being sent in the same way. Hence the structure of the GlideQuery, which I can only assume prompted your recommendation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2025 02:04 AM
Hi,
I have tried similar requirement and I've tried many like gel/setpreference etc but nothing worked. You can get the current window sys_id using below script in UI page(client script)