on 2013 Nov 28 12:01 PM
Hi experts,
I am using below link to send emails but the piece of code given in the link is working fine but it's not working in explicitly called script(triggered from a schedule task).
http://scn.sap.com/community/sourcing/blog/2012/12/21/sap-sourcing-custom-mail-message-templates
The piece of code is as below.
Line 1: Properties params = new Properties();
Line 2: params.put(new String("TOKEN1"), doc.getDisplayName());
Line 3: String[] recipients = {"vikram.shanmugasundaram@sap.com"};
Line 4: sender = session.getAccount();
Line 5: mailTypeEnum = new MailTypeEnumType(MailTypeEnumType.ODP_CUSTOM_TEMPLATE1);
Line 6: NotificationUtil.sendNotification(recipients,sender, mailTypeEnum,params,null,null);
I set loggs and checked.
statement NotificationUtil.sendNotification(recipients,sender, mailTypeEnum,params,null,null); is having error message which is exception due to null object reference.
as per my analysis, all parameteres are fine in logs except sender parameter.
sender.getFullName() is returning System Daemon.
Can you please let me know where am I making mistake.
Regards,
Ratnesh
Request clarification before answering.
Hi ,
Your script is not working because you are using doc , which is provided implicitly on business documents . As you are writing explicit script which does not take any scripting context you cannot use doc etc.
Try to write a query and get details of the document you are trying to retrieve.
Thanks
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Uday,
Thanks for reply.
I am not using doc in my actual code. I am using Sourcing APIs
projectHome = IBeanHomeLocator.lookup(session,ProjectIBeanHomeIfc.sHOME_NAME);
projectList = projectHome.findAll();
to retrieve all projects and then filling "display name".
Also, my script is triggering(I checked logs) and the flow of program is coming to the code of triggering email but the mail is not getting triggered.
Please advise.
Regards,
Ratnesh
Hi
Line 2: params.put(new String("TOKEN1"), doc.getDisplayName());
you can give like this :
docID=doc.getDocumentId();
vdocName=doc.getDisplayName());
Line 2: params.put(new String("TOKEN1"), vdocName);
it will work.
Kind Regards
V.Venakt
Message was edited by: Venkateswararao Vasantha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.