RE: From address from name default
Hi Nadine,
You could run a custom JavaScript function at OnLoad event of marketing email form to populate "from name" with business unit name of current user, and "from address" with a concatenated email address with bu name.
function autoPopulate(executionContext) {
var formContext = executionContext.getFormContext();
var globalContext = Xrm.Utility.getGlobalContext();
var currentUserID = globalContext.userSettings.userId.replace(/\{|\}/gi, "").toLowerCase();
Xrm.WebApi.retrieveMultipleRecords("systemuser", "?$select=fullname&$expand=businessunitid($select=name)&$filter=systemuserid eq '" currentUserID "' ").then(
function success(result) {
for (var i = 0; i < result.entities.length; i ) {
var businessUnitName = result.entities[i].businessunitid.name;
formContext.getAttribute("msdyncrm_fromname").setValue(businessUnitName);
var originalFromAddress = formContext.getAttribute("msdyncrm_fromemail").getValue();
var domain = originalFromAddress.substring(originalFromAddress.indexOf("@") 1, originalFromAddress.length);
formContext.getAttribute("msdyncrm_fromemail").setValue(businessUnitName "@" domain);
}
},
function (error) {
console.log(error.message);
}
);
}
Steps to add the custom function:
1. Top right gear icon > advanced settings > customizations > customize the system
2. Entities > Marketing email > Forms > Designer
3. Form properties: add custom JavaScript library > enable the custom function at OnLoad event of form.
Both of two options are required to be checked:
4. Save and publish the form.
Result:(I changed the real business unit name to sample name.)
The From name will be set to business unit name of current user.
The From address will be set to a concatenated email address with bu name and the original domain.
Regards,
Clofly