How to compare values in same column from different Records in a particular table.

Anup6
Kilo Contributor

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.

find_real_file.png

3 REPLIES 3

Community Alums
Not applicable

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

Upender Kumar
Mega Sage

You can use GlideAjax and in the script include you can use GlideRecord with your query.

Sravan15
ServiceNow Employee
ServiceNow Employee

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