cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the language of a mail template from NotificationUtil?

Former Member
0 Kudos

Hi experts!

I've been having some issues with the Message Template Language when using the NotificationUtil to send an Email.

How do I set the language of the template?

Do i set this by the sender? Or do I need to reference the recipient?

If so, how could I get the Account Object Interface from the user given that I got him as a collaborator?

I wish you could help me out whit this language problem.

Here's an example of the code I'm using:

Properties params = new Properties();

params.put(new String("PHASE_NAME"), faseName);

params.put(new String("DOCUMENT_TYPE"), docType);

params.put(new String("DOCUMENT_NAME"), contractName);

params.put(new String("OWNER_FIRST_LAST_NAME"), owner.toString());

params.put(new String("START_DATE"), fecha);

params.put(new String("INSTRUCTION"), "");

params.put(new String("DOCUMENT_HEADER_URL"), vinculo);

String[] recipients = {mail};

sender = session.getAccount();

mailTypeEnum = new MailTypeEnumType(MailTypeEnumType.ODP_WORKFLOW_APPROVAL_REQUEST_MSG);

NotificationUtil.sendNotification(recipients,sender, mailTypeEnum,params,null,null);

Thanks in Advance!

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Oscar,

There are 2 flavors of the sendNotification method, one takes IapiAccountIfc for recipient and the other takes a String array for recipients. Looks like you are using the one that takes a String array by passing a list of recipients email id. I'd suggest using the first one by passing the IapiAccountIfc for the recipient and the email sent out will be in the default language of that user. The default language for the user is set on the user account object.

Hope this helps.

Regards,

Vikram

Former Member
0 Kudos

Hi Vikram!

Thanks for the answer.

Now assuming I have a collaborator object (CollaboratorIBeanIfc) how can I get a IapiAccountIfc from that object?

I assume it would work with getParentObjRef(), but I'm not sure.

Thanks in advance!

0 Kudos

You can call the getPrincipal() method which will return the ObjectReference of the user.

Vikram

Former Member
0 Kudos

Hi vikram!

Sorry for the still inconvenience, but I'm getting this error:

Error in method invocation: Static method sendNotification( com.sap.odp.usermgmt.masterdata.UserAccountBo, com.sap.odp.usermgmt.masterdata.UserAccountBo, com.sap.odp.api.comp.messaging.MailTypeEnumType, java.util.Properties, null, null ) not found in class'com.sap.odp.api.util.NotificationUtil'

Im making the code the following way:

Properties params = new Properties();

params.put(new String("PHASE_NAME"), faseName);

params.put(new String("DOCUMENT_TYPE"), docType);

params.put(new String("DOCUMENT_NAME"), contractName);

params.put(new String("RECIPIENT_FIRST_NAME"), nombre);

params.put(new String("OWNER_FIRST_LAST_NAME"), owner.toString());

params.put(new String("START_DATE"), fecha);

params.put(new String("ORG_UNIT"), orgUnit);

params.put(new String("INSTRUCTION"), "");

params.put(new String("DOCUMENT_HEADER_URL"), vinculo);

recipients = IapiAccountLocator.lookup(session, collaborator.getPrincipal()); // This Changed.

( I also tried like this:

IapiAccountIfc recipients = IapiAccountLocator.lookup(session, collaborator.getPrincipal());)

sender = session.getAccount();

mailTypeEnum = new MailTypeEnumType(MailTypeEnumType.ODP_WORKFLOW_APPROVAL_REQUEST_MSG);

NotificationUtil.sendNotification(recipients,sender, mailTypeEnum,params,null,null);

Thanks again!

0 Kudos

Hi Oscar,

Couple of things....

The two flavors of sendNotification method has different method signatures. Please take a closer look at the IAPI.

For example, the parameter notificationType is an Integer not MailTypeEnum.

It will be something like this....

sendNotification(recipients, sender, new Integer(401), params);

Here 401 is nothing but the custom template 1. You can find this in the messaging.MailTypeEnum class on the reference guide.

Regarding collaborator variable - May be you have defined it somewhere in your script but I didn't find it in the code snippet you provided. To iterate through the collaborator collection, the code will look something like this....

docCollabIter = doc.getCollaborators().iterator();
while(docCollabIter.hasNext()){
    collab = docCollabIter.next();
    collabUserObjRef = collaborator.getPrincipal();

}

Hope this helps.

Regards,

Vikram

Former Member
0 Kudos

Hi Vikram!

It was indeed that the parameters from the second flavor where a bit different than the first one.

I transformed the MailTypeEnum into Integer, and removed the attachments and it worked!

Thanks a lot!

Answers (0)