Home › Forums › Classic DFFS › The list item was NOT saved: Error sending email
Tagged: DFFS Email
- This topic has 2 replies, 2 voices, and was last updated 2 years, 6 months ago by AdamP.
-
AuthorPosts
-
-
May 31, 2022 at 13:06 #35846
Hello
I’ve run into a slight issue using email functionality with SharePoint Online (with a DFFS_Email list). On form save, an error message pops up, the item isn’t saved to the sharepoint list and the email isnt written to the DFFS_Email list.
The issue appears to be related to using a people picker (to populate To: on the email), where the person in the picker, even though validated through the UI on the form, at that point in time hasnt been added to the UIL (https://Tenant.sharepoint.com/sites/SiteName/_layouts/15/people.aspx?MembershipGroupId=0)
Looking at the network calls in Dev Tools – it appears to be doing an old soap call to validate the user – which then fails as the user isnt in the UIL yet, returning a pop-up:
“The list item was NOT saved: Error sending email – Missing recipient for the email template TestSend. Please verify that you have a value in the “To” field in your email template (NameField) and then retry saving this item.”
(The To field definitely does have the correct setup – using a user already in the UIL, DDFS emailing works exactly as expected).Request URL: https://tenant.sharepoint.com/sites/SiteName/_vti_bin/lists.asmx
Which returns <rs:data ItemCount=”0″> when it failsAm I doing something fundamentally wrong with the set-up or is there any way to work around this? Ideally I need the form to work with any user, even if they’re not in the UIL immediately.
Thanks
AdamP
Attachments:
-
May 31, 2022 at 21:30 #35849
Hi,
This function does try to read the email from the site collection user list so when the user has not logged in or been selected (and saved) in a people picker it cannot read the email address.The historic reason for this is that earlier versions of SharePoint (that is still supported by DFFS) does not have the userprofile service.
To work around this issue you must use some custom js.
Add these two functions and the variable at the “root” of your custom js:
function getEmailFromUserProfile(fin){ var selectedUserLogin = spjs.utility.getFieldValue({"fin":fin, "key": "loginName"}); var userProfile = spjs.utility.userProfile(selectedUserLogin[0]); return userProfile.WorkEmail; } var userEmail = ""; function dffs_PreSaveAction() { userEmail = getEmailFromUserProfile("Your_people_picker_field"); return true; }
Please note:
If you have a dffs_PreSaveAction function already you must edit it to add the line to your current function.Now use this variable in your Email template (in the To field):
{var:userEmail}
Let me know how this works out.
Alexander
-
June 1, 2022 at 09:55 #35850
Thank you Alexander !
Works perfectly. Great answer and speedy reply as always.
-
-
AuthorPosts
- You must be logged in to reply to this topic.