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

Is there anyway to execute another action after sending an email in workflow rule?

dmak
Participant
0 Likes
915

On C4C, I have a workflow rule that watches a field, when that field changes value, it sends out an email, Now I want that field's value to reset back to the default value immediately after the email is sent out, is there anyway to execute another action after the field change via workflow rule? I tried creating a workflow rule to run on schedule 5 mins after "change on", but it didn't execute for some reason and I have no idea why it doesn't execute, so I'm forced to look for an alternative.

If workflow rule is not possible, what are the alternatives? I have looked at sap cloud studio and looked at the sample email code:.https://answers.sap.com/questions/234237/sap-c4c-send-email-by-custom-button.html but wasn't able to find documentation to explain that code further, for example, how to determine the party numbers, how to send from the system's email instead of sending from a particular employee. Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

former_member226
Employee
Employee
0 Likes

Hi,

You don't need to write a very long code in order to send out an email from C4C using a script. You can simply import AP.PlatinumEngineering and use Mail.Send() with the recipient as well as the content of the email.

mail-send.png

Once Email is sent then in the same action you can reset the value of the field whichever is needed by your business.

On a side note, Would be great if you can share the Workflow configured by you for 5 min delay as well. Ideally, it is possible to schedule the workflow based on the condition defined. However, note that that workflow configured with schedule/delay, cannot contain conditions where they compare the value before and after the change that's because by the workflow is executed, the new value is already persisted in the database and that might be causing the workflow condition to fail.

dmak
Participant
0 Likes

I tried following the code on this blog

https://blogs.sap.com/2017/09/25/sap-platinum-engineering-libraries/

to send email from the sap cloud studio but I wasn't able to find AP.PlatinumEngineering.Public, it wasn't available for me to select for some reason? I can import AP.PlatinumEngineering though. So some values such as EmailURI or sender.content are underlined in red by the environment.

If I use Mail.Send(...) I am not sure what to put for the subject as it doesn't accept string and I am not sure what is the syntax to put there, is there an example other than the blog I have found above?

Your reasoning around the workflow explains why my workflow failed, I was trying to use it to detect a field value change and it did not get triggered as you said. If I don't compare the before and after value of the field, how to get the workflow rule to trigger 5 minutes after that field changed?

former_member226
Employee
Employee

Hi,

You need to import AP.PlatinumEngineering library in order to utilize Mail.Send() feature. A working code can be found below:

import ABSL;
import AP.PDI.bo;
import AP.Common.GDT;
import DocumentServices.Global;
import AP.PlatinumEngineering;

var subject: String;
var body: XPEString;
var bodyTab: XPEStringTab;
var from: EmailURI;
var recipient: EmailRecepientData;
var recipientTable: EmailRecepientDataTable;

subject = "Sent from ABSL Script";
from.content = "saurabh@sap.com" ;

recipient.EmailUri.content = "saurabh123321@sap.com";
recipient.EmailRecepientTypeCode = "TO";
recipientTable.EmailData.Add(recipient);
recipient.EmailUri.content = "XSASDASASAS@gmail.com";
recipient.EmailRecepientTypeCode = "CC";
recipientTable.EmailData.Add(recipient);

body = "This is the body of email from C4C ABSL Script!!!";
bodyTab.XPEString.Add(body);

Mail.Send(subject,bodyTab,from,recipientTable);

Email received is as attached:

email.png

Thanks

Sarurabh

Answers (0)