How to compare values in same column from different Records in a particular table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2021 07:36 AM
We want to compare values from the particular Fields in all the records of a particular table. Like in the Normal incident table we want to compare the values from Service, Service offering and configuration item as highlighted below on all the records of incident table. If we find matches for all the 3 fields on 2 or more records we want to update the priority on the ticket by updating the impact on the ticket.
Can someone please suggest how do we compare these field values on all the records of the same table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2021 07:52 AM
Hi Anup,
Write a ONChange Client script :
var frompcowner = g_form.getValue('from_pc_owner');
var remotepcowner = g_form.getValue('remote_pc_owner');
if(frompcowner == remotepcowner ){
//Set to Yes
}else{
//Set to No
}
Please mark my answer as Correct & Helpful, if applicable.
Thanks
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2021 08:36 AM
You can use GlideAjax and in the script include you can use GlideRecord with your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2021 10:58 AM
Hi
I think you want to re Prioritize the incident based on a condition.
This looks good to use a Business Rule.
So every time a record gets updated we can check for the condition and update the field.
But
If you are looking to change all the records already in database, you can write a scheduled script to run once. (This will update the record in the backend, we don't have to click on the update of the each record opened)
Script :
var gr = new GlideRecord('<TABLE NAME>');
gr.addQuery('<COLUMN ONE>', '<COLUMN ONE VALUE>');
gr.addQuery('<COLUMN TWO>', '<COLUMN TWO VALUE>');
gr.addQuery('<COLUMN THREE>', '<COLUMNTHREE VALUE>');
//Update Priority
gr.setValue('<FIELD TO UPDATE>' , ' <UPDATED FIELD VALUE>');
gr.updateMultiple(); // This will update only the records that query conditions matched with
Thank You
Venkat Sravan