Skip to content

Custom Apex utility for merging strings containing merge fields and replacing with values

Notifications You must be signed in to change notification settings

bobbysfdev/apex-template-merger

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 

Repository files navigation

apex-template-merging

Custom Apex utility for merging strings containing merge fields and replacing with values

This utility provides a way to pass a string containing merge fields using {!field_name} syntax, and getting the SObject record value.

Eg.

String myTemplate = 'Hey {!FirstName}, your email address is {!Email} and account name is {!Account.Name}';

String myResult = MergeFieldUtility.replaceMergeFieldsWithValues (
  myTemplate, // The string to merge
  '0032800000YWeRQ' // The record ID
);

system.debug(myResult);

###[DEBUG]: Hey Ben, your email address is ben@edwards.nz and account name is Edwards Enterprises

About

Custom Apex utility for merging strings containing merge fields and replacing with values

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Apex 100.0%