HI,
Use below code on Onload of Email form.
function _setFromUser(executionContext) {
var formContext=executionContext.getFormContext();
var formType = formContext.ui.getFormType();
//var legalQueueID = "87644a7e-7869-ec11-8943-6045bda57288";
//var recordName = "87644a7e-7869-ec11-8943-6045bda57288";
alert("Form Type:"+ formType);
var entityName = "queue";
if(formType ==2 || formType == 1 || formType == 0) { //Return Value Client API Reference: docs.microsoft.com/.../getformtype
Xrm.WebApi.online.retrieveMultipleRecords("queue", "?$select=queueid,name&$filter=name eq 'Mailbox Queue'").then(
function success(results) {
console.log(results);
for (var i = 0; i < results.entities.length; i++) {
var result = results.entities[i];
// Columns
var queueid = result["queueid"]; // Guid
var name = result["name"]; // Text
formContext.getAttribute("from").setValue([{ id: queueid, name: name, entityType: entityName }]);
}
},
function(error) {
console.log(error.message);
}
);
}
}
Replace 'Mailbox Queue' with your Queue Name.
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/