- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 01:03 AM
Hello,
I have been trying to create a GlideRecord request to a data set in a script action. But I cant call the values of different fields in the data set through dot walking, even though I can call the sys id of the data set.
And when I run the code as a Background script it works just fine... Any idea why it doesnt work as a script action? Thanks!
My Code:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 02:23 AM
On this table of yours - do you have any query business rule running ?
Maybe try:
var request_id = event.parm2 //this is the sys_id I want to call
var data_set = new GlideRecord("table_name");
data_set.setWorkflow(false); //Disables query business rules that could prevent the user from seing the record
if (data_set.get(request_id)) {
gs.info("test Number: " + data_set.getValue("number"));
// Get Value function returns "null". (Not if I run this exact code as Background Script)
} else {
gs.info("Record not found");
}
I dont know if the table is in global scope, scoped app, or something similar (domain separation) that could also cause issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 01:27 AM
Are you sure that event.parm2 actually contains what you expect ?
Try logging out the parm first to check.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 02:01 AM
I tried it yes, it gets the expected value. I also set the request_id manually to check if that s the problem. It's not the reason why it doesnt work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 02:05 AM
I just tested it and had no issues triggering an event from a Business rule (on record update) and then trigger a script action on that event - looking up the record from the sys_id and printing out the number.
If you log out data_set.getDisplayValue() what do you get then ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 02:13 AM
I dont get anything back when I delete the if condition. I think there is a problem with the get function. I'm 100% sure the request_id has the correct value, because i just set the sys_id manually to that and got same results. With the current if condition I get "record not found" logged out.