Fix Script Help needed

Snow Angel
Tera Expert

Can someone help me tweek this Fix Script? It's not updating the records.

 

Requirement : Create and run a fix script that will change the Source field value for all existing Security Incidents (active or inactive) currently having a Source field displayed as self_service, so that the field will correctly display Self-service.

 

source field backend value is "contact_type"

 

var gr = new GlideRecord('sn_si_incident');
gr.addQuery('contact_type', 'self_service'); gr.query();  while (gr.next())
{gr.contact_type = 'Self-service';   gr.update(); }  gs.print("Fix script execution completed.");

 

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@Snow Angel Try with the following and see if it works.

 

var gr = new GlideRecord('sn_si_incident');
gr.addQuery('contact_type', 'self_service'); 
gr.query();  
while (gr.next()){
gr.contact_type.setDisplayValue('Self-service');   
gr.update(); 
}  
gs.print("Fix script execution completed.");

View solution in original post

4 REPLIES 4

swathisarang98
Giga Sage
Giga Sage

Hi @Snow Angel ,

 

while updating you will have to give the backend value of Self- service so try giving gr.contact_type ='self-service'

 

 

var gr = new GlideRecord('sn_si_incident');
gr.addQuery('contact_type', 'self_service'); 
gr.query();  
while (gr.next())
{
    gr.contact_type = 'self-service';   
    gr.update(); 
    
    }  
gs.print("Fix script execution completed.");
    

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

@Snow Angel  and try  addEncodedQuery instead of addQuery

Sandeep Rajput
Tera Patron
Tera Patron

@Snow Angel Try with the following and see if it works.

 

var gr = new GlideRecord('sn_si_incident');
gr.addQuery('contact_type', 'self_service'); 
gr.query();  
while (gr.next()){
gr.contact_type.setDisplayValue('Self-service');   
gr.update(); 
}  
gs.print("Fix script execution completed.");

Thank you Sandeep! It has worked.