Need to set the Assigned to value from another table assigned to field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 03:48 AM
Hi All,
I have a requirement i need to set the Assigned_to field value on alm_hardware from cmdb_ci_computer assigned_to.
we have a catalog item in the variable name called ( serial_number_all ) which is having name of asset. that asset name populated from cmdb_ci_computer in that that table we have( assigned to ) That value we need to populate to alm_hardware table assigned to.
below is the script in logs I'm able to see the user value but its not set in the assigned to field.
var ritmGR = new GlideRecord('cmdb_ci_computer');
if (ritmGR.get(current.variables.serial_number_all.toString())) {
ritmGR.query();
while (ritmGR.next()) { // loop through all records found
var someData1 = ritmGR.getDisplayValue('assigned_to');
var taskGR = new GlideRecord('alm_hardware');
taskGR.addQuery('install_status', '3');
taskGR.query();
if (taskGR.next()) { // only processes the first record
gs.log("datasome" + someData1); // im able to see the value in Log.
taskGR.assigned_to = someData1; //but its not set in the field
gs.log("datasome1" + assigned_to);
taskGR.update();
}
}
Please sugget.
Thanks all.
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 07:07 AM - edited 02-01-2024 07:10 AM
Hello @varma2
Can you please check on hardware record the CI field is not empty..!!!
Means it should refer to the CI which you are selecting in your 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
02-01-2024 08:05 AM
Hi @Vishal Birajdar ,
Yes, I have checked Ci field have the value, it not empty.
Please suggest.
Thanks
Varma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 05:04 AM
Hello @varma2
As you want to retrieve the value from server side and populate it on client side, you should use Client script plus script include combination with GLIDEAJAX API....
You can refer this youtube video for sample use case: https://www.youtube.com/watch?v=4unHkSkkT70&t=1850s
and modify your logic accordingly.
