I want to retrieve the script stored in JSON format and evaluate the script on other table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 10:47 PM
Hi All,
I am passing this JSON Format into my flow to update the fields on RITM form:
{"sys_db_object":"sc_req_item",
"short_description":"current.variables.variable_name.display_value,-,current.cat_item.name"}
This JSON is stored in a field in a table.
Suppose item name is "test" and variable value is "abcd"
So it should update the short description on RITM like this:
abcd - test
If I will use GlideScopeEvaluator, then what table and how I should specify.
What I should do to achieve this, pls help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2023 12:51 AM - edited ‎07-27-2023 12:56 AM
Hi @pandeyved ,
You need to use RITM table to update the short description of RITM and try the code like below.
var now_GR = new GlideRecord('sc_req_item');
now_GR.short_description =short_description ;
now_GR.insert();
//setup variables to be used by the script
var vars = {"sys_db_object":"sc_req_item","short_description":"current.variables.variable_name.display_value,-,current.cat_item.name"};
//Evaluate the script from the field
var evaluator = new GlideScopedEvaluator();
gs.info(evaluator.evaluateScript(now_GR, 'short_description ', vars));
// Now retrieve the result
evaluator.evaluateScript(gr, 'short_description', null);
gs.info(evaluator.getVariable('result'));
Please mark my answer as correct and helpful if it helps to resolve your issue.
Regards,
Namrata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2023 12:59 AM
Thanks for help!
I have one doubt here, pls clarify
How it will evaluate the script on ritm table,
gs.info(evaluator.evaluateScript(now_GR, 'short_description ', vars));
As short description in JSON is separated by comma and one more character is there which is "-".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2023 01:14 AM
Hi @pandeyved ,
You can write the code like below as well.
var vars = {"sys_db_object":"sc_req_item",
"short_description":"current.variables.variable_name.display_value,-,current.cat_item.name"};
var now_GR = new GlideRecord('sc_req_item');
now_GR.short_description=vars.short_description;
now_GR.insert();
Please refer the below link.
Please mark my answer as correct and helpful if it helps to resolve your issue.
Regards,
Namrata