Show List collector value in the email created in Flow designer

Samiksha2
Mega Sage

Hi All,

 

I have added send email action in the Flow designer to send variables in the email.

 

List collector values are not populating in the email. Is there any way to show List collector value?

 

Samiksha2_0-1703150084775.png

Please help in this.

 

Thanks, 

Sam

1 ACCEPTED SOLUTION

VaishnaviShinde
Kilo Sage

Hello @Samiksha2 

 

If I understood correctly, you have to add the list collector values to the email body. You can try the below script in body section of "Send Email" action. 

 

In the below highlighted section you can add the script. 

VaishnaviShinde_0-1703153155895.png

 

 

var originalGroup = [];
var groups = fd_data._1__get_catalog_variables.groups; // You can take your get catalog variable number
gs.info('Groups:'+groups.length);
var listSplit = groups.split(',');
gs.info("MS 29==" + listSplit);

for (var i = 0; i < listSplit.length; i++) {
originalGroup.push(listSplit[i]);
}
gs.info("MS 18 ==" + originalGroup.length);
var string = "this are the groups:";
var group="";
for(var i=0;i<originalGroup.length;i++){
var groupGr= new GlideRecord('sys_user_group');
groupGr.addQuery('sys_id',originalGroup[i]);
groupGr.query();
if(groupGr.next()){
if(group == ''){
string = string+ ', '+ groupGr.name;
}else{
string = ', '+ groupGr.name;
}
}
}
return string;
 
Output 
VaishnaviShinde_1-1703153235884.png

 

This works for me.

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Vaishnavi Shinde

 

 
 

View solution in original post

16 REPLIES 16

Hello @Samiksha2,

 

You can add the other variables as well in the flow use get catalog variables actions add all the variables of catalog in that and then body use that variable by using "fd_data" option. like same mention in provided script.

 

What is the trigger of your flow? can you share some more details? so I can help you to solve your issue.

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Vaishnavi Shinde

 

Hi @VaishnaviShinde ,

Thanks for helping.

I have to return these variables in the email

Samiksha2_0-1703155258593.png

 

in the areas the list collector should populate. Everything is populating except List collector variable.

 

Thanks,

Sam 

Hi @VaishnaviShinde ,

 

I have created Custom action and added your code and made some changes in that.

Now i am getting the value. Thank you for your help.

 

Thanks,

Sam

Hello @Samiksha2 ,

 

Please try below script in flow designer.

 

var originalGroup = [];
var group="";
var groups = fd_data._1__get_catalog_variables.groups;// Add your variable
gs.info('Groups:'+groups.length);
var listSplit = groups.split(',');
gs.info("MS 29==" + listSplit);

for (var i = 0; i < listSplit.length; i++) {
originalGroup.push(listSplit[i]);

}
gs.info("MS 18 ==" + originalGroup.length);


for(var i=0;i<originalGroup.length;i++){
var groupGr= new GlideRecord('sys_user_group');// Add your table
groupGr.addQuery('sys_id',originalGroup[i]);
groupGr.query();
if(groupGr.next()){
if(group == ''){
gs.info('group:'+group)
group = groupGr.name;
}else{
group = group + ', '+ groupGr.name;
}
}
 
}
gs.info('group:'+group);
var string = "Request Details \nRequest:"+fd_data.trigger.request_item.request.number+' \nCatalog Task:'+fd_data.trigger.request_item.cat_item.name+' \nSubmitted On:';
string = string +''+ fd_data.trigger.request_item.opened_at+ ' \nReuested By:' + fd_data.trigger.request_item.opened_by.name+' \nAreas:'+group;

return string;
 
Output:
VaishnaviShinde_0-1703157633792.png

 

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Vaishnavi Shinde

@VaishnaviShinde  good one ! Just curious to know..

 

Whats the diffrence in using 'get catalog varaible' action and  'fd_data._1__get_catalog_variables.groups'.

Event 'get catalog varaible' action will return string of comma seprated vaules Why are we not able to use those returned value and why do we use 'fd_data._1__get_catalog_variables.groups'.

 

 

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect