- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 03:45 AM
Hello,
I am attempting to create a metric script which will copy content from 2x columns. The conditions would be if the row is empty do not copy read and copy the alter row.
Example:
Meeting | CAB | Final results |
1234 | 1234 | |
2222 | 2222 | |
5678 | 5678 | |
9101 | 9101 | |
4321 | 4321 | |
1116 | 1116 | |
5732 | 5732 |
Thank you,
var now_GR = new GlideRecord('u_chg_cab_definition_view');
now_GR.addQuery();
now_GR.query();
var count = now_GR.getRowCount();
if (count > 0) {
var allocation = 'met_cab_definition';
while (now_GR.next()) {
now_GR.u_allocation = 'chg_u_cab_meeting';
now_GR.update();
}
}
Solved! Go to Solution.
- Labels:
-
Dashboard
-
Performance Analytics
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 03:51 AM
Hi Don,
This code will let you iterate over the entire table and update the final result field if meeting or cab it is not empty:
var now_GR = new GlideRecord('u_chg_cab_definition_view');
now_GR.query();
while(now_GR.next()) {
if(now_GR.meeting != '') {
now_GR.final_result = now_GR.meeting;
}else{
now_GR.final_result = now_GR.cab;
}
now_GR.update();
}
If it was helpful, please give positive feedback.
Thanks,
☆ Community Rising Star 22, 23 & 24 ☆
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 03:51 AM
Hi Don,
This code will let you iterate over the entire table and update the final result field if meeting or cab it is not empty:
var now_GR = new GlideRecord('u_chg_cab_definition_view');
now_GR.query();
while(now_GR.next()) {
if(now_GR.meeting != '') {
now_GR.final_result = now_GR.meeting;
}else{
now_GR.final_result = now_GR.cab;
}
now_GR.update();
}
If it was helpful, please give positive feedback.
Thanks,
☆ Community Rising Star 22, 23 & 24 ☆
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 07:16 AM
Many thanks for all your help, much appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 03:52 AM
What if both columns will have values? or this scenario is not possible?
What if both columns will have empty values, would you like to consider these 2 scenario as well in your script?
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 04:22 AM
Hello Abhijit,
Thanks for your help! Good question, I should have pointed this out from the beginning that a additional filter will be applied on column called "type=CAB" which will ensure each scenario would work perfectly.
So how would I modify your script to accommodate column filter "type=CAB"?
Thanks again
-Don