cancel
Showing results for 
Search instead for 
Did you mean: 

Add custom recipient in workflow rules

Former Member
0 Kudos

Dear experts,

is it possible (and how) to add a custom recipient in workflow rules? Is something inside fine tuning or need custom development?


I need this because we want to send and e-mail to the customer (or to the contact of the customer) when created.

thanks a lot in advance

View Entire Topic
leigh_mason
Employee
Employee
0 Kudos

Hey there,

I know this is a very very old post, I've recently had a requirement where I had to send an Email to a newly created contact.

We obviously want to be able to do this in a nice configurable way using the workflow rule however I ran into the snag where you cannot select the Contact Email address as part of the standard recipient determination, therefore I started looking at the custom rule in SDK.

Although this may not help you now, I've managed to successfully do this so wanted to share the information with the community so at least if someone has the same requirement they'll be able to find an answer because I really struggled to find anyone who has done this.

So you can create your own custom recipient determination, please follow this blog: https://community.sap.com/t5/application-development-blog-posts/recipient-determination-in-workflow-...

Now I had the problem as others have had trying to find out when the workflow is triggered, all you have is the InputData.TriggeredBOUUID of the contact, i first thought it may not be possible to get the Contact details in case it hadn't been saved yet but it turns out you can retrieve the newly created Contact email address, insert the email address and the Contact UUID into the result of the rule and presto, you have an Email Activity created against the Contact as well as the outbound email from C4C ( that's if you've flagged "Create Email Activity" as well ).

So here is a code snippet that I used that is working nicely ( DefaultIsContactPersonForBusinessPartnerRelationship.ContactPerson.ContactPersonWorkplaceAddressInformation.ContactPersonWorkplaceAddress.DefaultEMail <-- was killing me trying to get to this bit 😕 )

 

 

var lo_contact : BusinessObject::BusinessPartner;
var lo_email : BusinessPartnerRelationship.ContactPerson.ContactPersonWorkplaceAddressInformation.ContactPersonWorkplaceAddress.EMail;
var ls_email : OutputStructureForWorkflowGetCustomRecipient.AgentEmail;
var ls_recipient_agent : WorkflowCustomRecipientAgents;
var result : OutputStructureForWorkflowGetCustomRecipient;
 
lo_contact = BusinessPartner.Retrieve(InputData.TriggerBOUUID);
 
if (lo_contact.IsSet())
{
       lo_email = lo_contact.DefaultIsContactPersonForBusinessPartnerRelationship.ContactPerson.ContactPersonWorkplaceAddressInformation.ContactPersonWorkplaceAddress.DefaultEMail;
       if (lo_email.IsSet())
       {
             ls_email.content = lo_email.URI.content;
             ls_recipient_agent.AgentUUID = InputData.TriggerBOUUID;
             result.AgentUUID.Add(ls_recipient_agent);
             result.AgentEmail.Add(ls_email);
       }
}
 
return result;

I hope this helps someone looking for answers 🙂

Cheers

Leigh