cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP Sourcing mail is not triggered in explicitly called script

RatneshSisodiy1
Active Participant
0 Likes
295

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

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

RatneshSisodiy1
Active Participant
0 Likes

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

Answers (1)

Answers (1)

Former Member
0 Likes

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

RatneshSisodiy1
Active Participant
0 Likes

Hi Vasantha,

Thanks for reply.

at line params.put(new String("TOKEN1"), doc.getDisplayName()). even if I am passing doc.getDisplayName() as hard-coded string "my name" then also the mail is not getting triggered. Please advise.

Regards,

Ratnesh