use fix script to update all location records name field with comma separated existing value and country field value.

shashank32
Giga Contributor

use fix script to update all location records name field with comma separated existing value and country field value.

can anyone help .

1 ACCEPTED SOLUTION

@shashank 

Hope you are doing good.

Did my reply answer your question?

If so, please mark it correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Can you share what you've tried so far? Can you share where you are stuck? Can you share where exactly you need help with?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Akshay H Mulky
Kilo Guru

Hi,

Can you try below script:

var gr = new GlideRecord('cmn_location');
//gr.addQuery('sys_id', 'xsdsfdfeeffsfsfw345r'); // testing with one record
gr.query();

while(gr.next())
{
gr.name+= ", " + gr.country.getDisplayValue();
gr.update();
}

Ankur Bawiskar
Tera Patron
Tera Patron

@shashank 

Not sure what exactly is required but here are the steps for fix script

1) left nav type fix scripts

2) create new

3) Give name, select Run Once

4) Sample script below

updateLocation();
function updateLocation(){
	try{
		var gr = new GlideRecord('cmn_location');
		gr.query();
		while(gr.next()){
			// your logic of updating here
		}
	}
	catch(ex){
		gs.info(ex);
	}
}

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Shashank 

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader