- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2018 12:57 PM
I'm hoping someone can help me out with an issue that I'm having that I can't seem to get working correctly. I've read a lot of posts here but nothing has quite worked the way that I'm hoping it will.
I have a new Service Catalog offering that I've set up, and on that offering I have a variable that is a List Collector pointing to a custom table, u_external_user. This table is used to hold individuals like visitors, vendor personnel, people coming to interview, etc. and is referenced by other apps in the system that we have for visitor management, NDAs, etc. The list collector would allow selections from this table, or if a record for the person doesn't exist, a button will allow for a UI Page popup to add a new record to the table and automatically add the new entry to the right hand slush bucket.
Upon submitting the catalog item though, I would like to be able to then take the people selected in the list collector and push that information to a string field on the form, but also get other information about them from the table as well. If possible, having the field formatted for readability would be great. As an example, if John Smith is selected in the list collector, in the string field I'd like to display his name, company, email address and phone number (as pulled from the table) and then display it like:
John Smith, Company Name, email address, phone number
If there is more than one person selected, I'd like to see a line break between each person's information.
So far the examples I've seen here don't seem to work for me in testing. I've tried to just dump an array to a field like Description, but on submit nothing appears there. Any help is greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2018 01:55 PM
I think you best option is to create a multi-line text variable on the item and only display it on the task level. Then in your workflow use a run script will the following code.
var list = current.variables.List collector variable name.toString.split(',');
for (i = 0, i < list.length, i++){
var gr = new GlideRecord ('table name');
gr.addquery('sys_id', list[i]);
gr.query();
if (gr.next()){
current.variables.multi-line variable name += gr.u_name + ", " + gr.u_company_name + ', ' + gr.u_email_address + ', ' + gr.u_phone_number + '\n';
}
in the above script in the if section you would have to use you filed names from the table. I just took a guess.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2018 01:06 PM
are you trying to display the test like below when the user is submitting the form or is this something that you want to display at the task level?
John Smith, Company Name, email address, phone number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2018 01:41 PM
I want this to display at the task level. Ideally, once the user has submitted their request via the Service Catalog the records selected in the list collector would then be displayed in a string field on the task form, and also pull in other fields related to that record such as company, email address etc.
I think that if I'm able to do that, the field would be a quicker, plain text way to view the information versus someone having to click on each list collector selection in the variable formatter (that will also be available in a tabbed form section) to view the relevant information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2018 01:55 PM
I think you best option is to create a multi-line text variable on the item and only display it on the task level. Then in your workflow use a run script will the following code.
var list = current.variables.List collector variable name.toString.split(',');
for (i = 0, i < list.length, i++){
var gr = new GlideRecord ('table name');
gr.addquery('sys_id', list[i]);
gr.query();
if (gr.next()){
current.variables.multi-line variable name += gr.u_name + ", " + gr.u_company_name + ', ' + gr.u_email_address + ', ' + gr.u_phone_number + '\n';
}
in the above script in the if section you would have to use you filed names from the table. I just took a guess.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 03:11 PM
I was hoping to do something along these lines. If you wanted to do this in a variable set instead and have a list collector and a box or some way to show the user details (such as user ID, email) on the task level I'm assuming you'd have to do that with a client script, probably on submit and probably with a get_value instead of current.variable. Any advice on how that would look?
