How to auto populate location in REQ

SN2024
Tera Contributor

Hi, 

Can someone please advise how I can configure REQ form to populate location based on the "Requested for" user?

 

I have been able to create business rule to populate the location for the new requests but for the existing ones I can't figure out what I need to select in Form Builder under location to make it work.

I have tried dot walking in location, dependent field to the "Requested for" location but that didn't work.

 

Thank you for your help.

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@SN2024 

you can use a fix script to update it for older REQs

Something like this

updateLocation();

function updateLocation() {
    try {
        var req = new GlideRecord('sc_request');
        req.addEncodedQuery('locationISEMPTY');
        req.query();
        while (req.next()) {
            req.location = req.requested_for.location;
            req.setWorkflow(false);
            req.update();
        }
    } catch (ex) {
        gs.info(ex);
    }
}

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

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@SN2024 

you can use a fix script to update it for older REQs

Something like this

updateLocation();

function updateLocation() {
    try {
        var req = new GlideRecord('sc_request');
        req.addEncodedQuery('locationISEMPTY');
        req.query();
        while (req.next()) {
            req.location = req.requested_for.location;
            req.setWorkflow(false);
            req.update();
        }
    } catch (ex) {
        gs.info(ex);
    }
}

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