Email from postUpdate Script does not evaluate {{object.givenName}} from Email template and also locale

====postUpdate Script on Managed User(alpha_user)==

var params = new Object();
params.to = newObject.mail;
params.templateName = “ProfileUpdate”;
openidm.action(“external/email”, “sendTemplate”, params);

=========

This script send email when any attribute is updated in Managed alpha_user profile.

Issue: When it sends email from template, it does not evaluate {{object.givenName}} / {{object.xxxxxxxxx}} from Email template.

Also, it always send email in single locale which is set as default and not other locales like de / fr.

I have gone through the REST API call to send email using template but this has very limited options.
openidm.action(“external/email”, “sendTemplate”, params);

Could you please help me to know how can I get below evaluated from Script / from template or just display “Dear ” in Email and also send locale based email.

Dear {{object.givenName}}

Hi @tanu.garg,

You did not set givenName in the “object” key for the request body (e.g params).

var params = {
      "templateName": "ProfileUpdate",
      "to": newObject.mail,
       "object" : {
             "givenName": newObject.givenName
       }
};
openidm.action(“external/email”, “sendTemplate”, params);

With regard to the locale, do you exercise this scenario with a browser set in the “fr” or “de” locale? IDM should receive an “Accept-Language” header, and openidm.action to propagate it (e.g the locale should be in the context) - if not, then you might need to log a support issue.

Regards
Patrick

2 Likes

@patrickdiligent - perfect! this works. Thank You very much!

I think issue was the below format I was using

var params = new Object();
params.to = newObject.mail;
params.templateName = “ProfileUpdate”;

“object” : { // this format in this piece of code was a error
“givenName”: newObject.givenName
}
params.givenName = newObject.givenName; ← Never worked
object.givenName = newObject.givenName; <-Never worked

openidm.action(“external/email”, “sendTemplate”, params);

For locale - I verified the Accept Language Header = de but still the email received is in english, I’ll create a support ticket.

2 Likes