Skip to main content
Answer

Email Template from Opportunitie

  • February 27, 2024
  • 2 replies
  • 57 views

Forum|alt.badge.img+1

I would like to add an action to the Opportunity screen that would load an email template, populate the template with fields from the Opportunity.

The part I struggle with is how to load template X and have the fields populated in an email activity.

 

 

Best answer by Zoltan Febert

You can get an email template like this:

var templateID = "your template ID";

var notification = PXSelect<Notification,
Where<Notification.notificationID, Equal<Required<Notification.notificationID>>>>
.Select(Base, templateID);

Once you have it, you can modify the body:

notification.Body = notification.Body.Replace("{YourField}", yourValue);

 

2 replies

Zoltan Febert
Jr Varsity I
Forum|alt.badge.img+3
  • Jr Varsity I
  • Answer
  • February 27, 2024

You can get an email template like this:

var templateID = "your template ID";

var notification = PXSelect<Notification,
Where<Notification.notificationID, Equal<Required<Notification.notificationID>>>>
.Select(Base, templateID);

Once you have it, you can modify the body:

notification.Body = notification.Body.Replace("{YourField}", yourValue);

 


Forum|alt.badge.img+1
  • Author
  • Varsity I
  • February 29, 2024

Okay, I started with the above comment. it works, I was just thinking there was a more elegant way. Thanks!