How to add list collector of location in the approver table for if approver is the Contact

Samiksha2
Mega Sage

Hi All,

I have a catalog item in which a variable is a list collector (cmn_location). 
In the location table I have added the contact for each location.
The flow is approver will go based on selected location's contact. (This is working).
The requirement is in the approver table that location should be populate for which contact is approving.

For example,
In the location table
Location 1 has User 1 contact

Location 2 has User 2 contact

Location 3 has User 1 contact

Location 4 has User 1 contact

And in the catalog item end user has selected Location 2, Location 3,Location4

In the Approver table, in the string value for User 1 Location 3 and Location 4 should populate and for User 2 Location 2 should populate.


The reason behind doing this is they want a report where stakeholder can see who approves which location.
I have created a database view for requested item and approver table.
But I am unbale to get the list collector values separately. 

If any other way to to do this, please let me know.

Thanks,
Sam
 

 

28 REPLIES 28

Shivalika
Mega Sage

Hello @Samiksha2 

 

List collector values you won't be able to get separately like that. You need to create a custom string field and use some script. 

 

Below 👇 client side if there is no dot walking required. 

 

var listCollectorValues = gForm.getValue('<LIST_COLLECTOR_VARIABLE>'); 

 

if (listCollectorValues) {

    var valuesArray = listCollectorValues.split(','); // Convert to array

    var commaSeparatedString = valuesArray.join(', '); // Convert back to string with commas

 

    gForm.setValue('<TARGET_FIELD>', commaSeparatedString); // Populate target field

}

 

Or server side thing like flow (preferably) or BR(last resort) - to auto populate that.

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Ankur Bawiskar
Tera Patron
Tera Patron

@Samiksha2 

are you having any custom field to hold reference to cmn_location?

share what have you done so far and share screeenshots

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 Bawiskar ,
No I haven't created any custom table. 
I am using OOTB Contact field in the location table.

This is the location table

Samiksha2_0-1743050352826.png

This is the catalog item

Samiksha2_1-1743050454321.png

I have selected two locations, so the approver will go to Biprajit and Daniel.

And when they will open their approval form, INDIA- Visitor Access should populate in Biprajit approval form custom field and BRK - PC Techs should in the Daniel's.

Stakeholder wants a report where they can see who approves which location. 
So I thought if I can add the values in approval table in the custom string field which will store the values of Location.(Based on selected location in the form and approval).

Samiksha2_2-1743050812093.png

 



Thanks,
Sam

@Samiksha2 

you can use 1 more database view table for cmn_location and use this

Table               Order    Prefix          Where clause

cmn_location 300       loc               loc_contact=a.approver

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