- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 02:57 AM
Hi,
I want to get the value of the "Select the software/system" and fill a field in the form of the RITM with this value.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 03:37 AM - edited ‎10-13-2023 03:39 AM
If you are using "gr.get()" , you need to use sys_id of that record
var mrvs;
var itemID = 'ab223sajnjsb7r3rr4t'; //set here sys_id of ritm record
var ritmGR = new GlideRecord('sc_req_item');
if (ritmGR.get(itemID)) {
mrvs = ritmGR.variables.var1;
ritmGR.setValue('u_business_application',mrvs);
ritmGR.update();
}
gs.print(mrvs);
OR
Try this
var mrvs;
var itemID = "RITM0010246";
var ritmGR = new GlideRecord('sc_req_item');
ritmGR.addQuery('number',itemID);
ritmGR.query();
if (ritmGR.next()) {
mrvs = ritmGR.variables.var1;
ritmGR.setValue('u_business_application',mrvs);
ritmGR.update();
}
gs.print(mrvs);
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 03:40 AM
By the looks of it u_business_application is a reference field, it will only take the value of var1 if it is present on the table it references.
Can you add logs like below and show that values you get
var mrvs;
var itemID = 'RITM0010246';
var ritmGR = new GlideRecord('sc_req_item');
if (ritmGR.get(itemID)) {
gs.print('came here 1');
mrvs = ritmGR.variables.var1;
gs.print('mrvs = '+ mrvs );
ritmGR.setValue('u_business_application',mrvs);
ritmGR.update();
}
gs.print(mrvs);
Once you get the value of mvrs, try to set the same thing on u_business_application on form and see if you can do it manually.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 03:00 AM
Hi @mregragui_ext,
You can do that within the flow or workflow for this catalog item.
Which are you using?
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 03:01 AM
Need some more information like...
1.Which table "Select the software/ system" is referencing ..?
2.On which condition the variable should filled means any dependency on other variable
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 03:07 AM
1.Which table "Select the software/ system" is referencing ..?
the table is business application
2.On which condition the variable should filled means any dependency on other variable
when the user is creating a ritm in the service portal there is a formular with a filed called Select the software/system then this field get dispaly with variable formatter in the form of the ritm i want to get the value of this variable and fill the Business app with this value if Select the software/system is not empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 03:13 AM - edited ‎10-13-2023 03:15 AM
You can use run script activity within workflow & try below script :
/*1. Get value of "select the software/ system" variable*/
var getSoftSyst = current.variables.<your_variable_name>; // "select the software/ system" variable backend name
/*2. Update the current ritm Business application if software/system */
if(getSoftSyst != ''){
current.business_app = getSoftSyst; // use the backend value of "Business application" field
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates