location not getting pouplated in list viwew in request

KashikaJ
Tera Contributor

I have written a client script to populate the location is REQ form the location is getting populated in form view but the location is not getting populated in List view. How can this be fixed.

1 ACCEPTED SOLUTION

@KashikaJ 

please use before insert/update business rule on sc_request and don't use client script

BR Order: 10000

BR Condition: current.requested_for != ''

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.location = current.requested_for.location;

})(current, previous);

Also ensure the location field on form is REQ own field and not dot walked field

OR Best Way

If customer only wants to see the Location on REQ then why not show Requested For->Location on form as dot walked field. This way no scripting is required.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@KashikaJ 

you should save the form so that location is stored in database.

the form field is a dot walked field or REQ's own location field?

share your screenshots and the script etc

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi Ankur,

 

Attaching the snip that i am using to get the location populated in REQ

KashikaJ_0-1745387803995.png

Thanksfor responding

@KashikaJ 

is the form getting saved?

If yes then the location on REQ list should show the correct value

Did you check the XML of that record to know if location got populated?

Also did you ensure no other script is clearing this value when record is getting saved?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi Ankur

 

I checked the XML is not saving tht location details not sure why. can you help me with this how can the location be saved in XML?

Attaching the snip for reference.

KashikaJ_0-1745389454456.png

Regards,

Kashika