This topic has 6 replies, 4 voices, and was last updated 2 years, 7 months ago by jelikapahwa.
-
AuthorPosts
-
December 1, 2017 at 8:50 am #19832
Dhakad
ParticipantHi,
I am working on a test scenario and want to send a email on user creation to his manager. To configure this create a new “triggerEmailNotification.js” and calling it in the managed.json as per the below format. After this configuration able to send mail tp “object.mail” but not able to send mail to manager. Please suggest way to achieve this
————————————–managed.json——————————————————————————
“PostCreate” : {
“type” : “text/javascript”,
“file” : “ui/triggerEmailNotification.js”
}
—————————————triggerEmailNotification.js———————————————–This is the function write to sent email to manager (Working if use to”: object.mail,)function sendVerificationEmail()
{
var emailConfig = openidm.read(“config/external.email”);var obj=openidm.read(‘managed/user/manager’);
if(emailConfig){
var email = {
“from”: emailConfig.from,
“to”: obj.mail,
“subject”: “Verification Email”,
“type”: “text/html”,
“body”:”test”
};
openidm.action(“external/email”, “sendEmail”, email);
}};
Thanks,
Bherulala DhakadDecember 1, 2017 at 8:55 am #19833Dhakad
Participant———————————error logs for the above topic——————————————-org.forgerock.openidm.servlet.internal.ServletConnectionFactory$3 handleException
WARNING: Resource exception: 500 Internal Server Error: “postCreate script encountered exception”
org.forgerock.json.resource.InternalServerErrorException: postCreate script encountered exception
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot read property “mail” from nullDecember 1, 2017 at 4:34 pm #19845Jake Feasel
Moderatorvar obj=openidm.read('managed/user/manager');
is returning null, this is why you are getting the error. You need to change this to read from the “/manager” endpoint under the particular managed/user you are working with, like so:var obj=openidm.read('managed/user/'+object._id+'/manager', null, ['*']);
The last parameter is the “fields” – you need to specify that you want to expand the relationship to the manager in order to get the email details.
-
This reply was modified 3 years, 2 months ago by
Jake Feasel.
December 1, 2017 at 5:16 pm #19847Dhakad
ParticipantHi,
Now am getting null point exception error. Error logs areDec 01, 2017 4:15:12 PM org.forgerock.openidm.servlet.internal.ServletConnectionFactory$3 handleException
WARNING: Resource exception: 500 Internal Server Error: “postCreate script encountered exception”
org.forgerock.json.resource.InternalServerErrorException: postCreate script encountered exception
at org.forgerock.json.resource.ResourceException.newResourceException(ResourceException.java:231)
at org.forgerock.script.exception.ScriptThrownException.toResourceException(ScriptThrownException.java:115)
Caused by: org.forgerock.script.exception.ScriptThrownException: Wrapped java.lang.NoSuchMethodException: Method not found warn(null) java.lang.NoSuchMethodException: Method not found warn(null)
at org.forgerock.script.javascript.RhinoScriptEngine$3.newScriptThrownException(RhinoScriptEngine.java:406)
at org.forgerock.script.javascript.RhinoScript.eval(RhinoScript.java:298)
at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
Caused by: java.lang.NoSuchMethodException: Method not found warn(null)
at org.forgerock.script.scope.FunctionFactory$1$2.call(FunctionFactory.java:92)
at org.forgerock.script.scope.FunctionFactory$1$2.call(FunctionFactory.java:81)
at org.mozilla.javascript.gen.file__app_openidm_bin_defaults_script_ui_triggerEmailNotification_js_250._c_anonymous_1(file:/app/openidm/bin/defaults/script/ui/triggerEmailNotification.js:10)
at org.mozilla.javascript.gen.file__app_openidm_bin_defaults_script_ui_triggerEmailNotification_js_250.call(file:/app/openidm/bin/defaults/script/ui/triggerEmailNotification.js)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)Thanks,
Bherulal DhakadDecember 4, 2017 at 11:47 am #19926[email protected]
Participantgiven the trace, you probably try to do some logging in triggerEmailNotification line 10. It has to be “logger.warn” in javascript, groovy would use log.warn.
December 8, 2017 at 2:27 pm #20013Dhakad
ParticipantThanks for your support.
Working now. Split the read operation.
1) Read the User ID “._id”
2) Read the Manager “._ref”Regards,
Bherulal DhakadJuly 16, 2018 at 5:44 am #22549jelikapahwa
Participant@dhakad -Could you please share the working transformation script , Actually i am provisioning manager attribute to CSV but its returning null .I am using “openidm.read(source._ref).username” in Transformation script.
Appreciate if you could help .
Thank You
-
This reply was modified 3 years, 2 months ago by
-
AuthorPosts
You must be logged in to reply to this topic.