Email scripts not working for multi selection field

Email scripts not working for multi selection field

Anonymous
Not applicable
823 Views
5 Replies
Message 1 of 6

Email scripts not working for multi selection field

Anonymous
Not applicable

Hi,

 

I had written a script to send email when a request go into a state, However, the APPLY_FOR_MACHINE field is a multi select picklist field.

If a user only select one option, then the email will went out well however if there is multi selection then the email will be a mess. 

 

var email = new Email();

email.to = 'Tommy@xxx.com, Chris@xxx.com';
email.cc = 'Carol@xxx.com';
email.subject = 'Spare Equipment Part Release Alert '+item.REQUEST_NUMBER+ ' '+item.APPLY_FOR_MACHINE+' ';
email.body = '<html><body><p><span style="color:blue;font-weight:bold;font-size:25">Workflow Notification</span></p>Hi Tommy and Chris,</br><br>'+item.REQUEST_NUMBER+' '+item.APPLY_FOR_MACHINE+', has been placed for release by '+item.master.owner.firstName+' '+item.master.owner.lastName+ 
'<br/><html><body><br><div style="text-align: left; padding-left: 200px"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a href="https://memjet.autodeskplm360.net/workspace#workspaceid=88&amp;dmsid=' + dmsID +
'&amp;tab=itemdetails">Click link to view Item Details for ' + item.descriptor.descriptor + '';

email.send(); //send email to user

 

 

0 Likes
Accepted solutions (1)
824 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Hi,

 

My apologies, I noticed my lower part of my post description was not posted, no wonder nobody can understand my issue, let me re post the missing description. 

 

As mention on my first post, I had written a script to send email to users when a workflow request has proceed to a state, however one of the field, the APPLY FOR MACHINE field is a multi selection field, when a user make a single selection, my email script work well however, when a user make multi selection, the email will print out all the selection and also my script as well.

 

I had attached the output of a single selection email and a multi selection email.

 

May I know, has anyone encounter this before or maybe can share your experience on how to send paragraph using scripting? 

 

Any help will be deeply appreciated.

 

Thank you very much.

 

Best regards,

Carol Mak

0 Likes
Message 3 of 6

Anonymous
Not applicable

So to confirm, the email addresses are working, but the multiple info selected in the multi-select field are not correctly outputted to the email?

I'm able to send an email with the items in the multiselect field in the body of my email.

 

The only issue I see is the order of the items may not be correct.

 

 

Message 4 of 6

Anonymous
Not applicable

Hi leungicp,

 

Appreciate your reply.

May I know did you try using my script or you have your own? If you have a script, may I look at how you compose the body of the email.

I would not mind the selection is not in order but I do not want my script to appear at the bottom of the email.

 

Thank you.

 

 

Best regards,

Carol Mak

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

I used my own script.  I think your question is the formatting of the email.  I would create a test script to focus only on item.APPLY_FOR_MACHINE.  See what happens when you choose 1 item and send to yourself.  See what happens to the formatting when you choose 2 items and send to yourself.  Knowing this, then you can build your email body with all the other information required.

0 Likes
Message 6 of 6

john.denner
Advocate
Advocate
Accepted solution

Your subject line may be the issue. You can see this in the first part of the bad email where the values you attempted to put into the subject spilled out of the header information into the body of the email.

 

So my first test would be to simplify the subject and try again. 🙂

 

email.subject = 'Spare Equipment Part Release Alert ' + item.REQUEST_NUMBER + ' ' + item.APPLY_FOR_MACHINE;
email.subject = 'Spare Equipment Part Release Alert ' + item.REQUEST_NUMBER;