web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Remove Send from Queue Only - Custom Form

(0) ShareShare
ReportReport
Posted on by 5

Hello,

I am not a developer, just a support specialist who is trying to fix a few things without escalation.

On our default Email form, we currently have an issue where we can't send from a user account (with Dynamics-enabled and Outlook connected) but only from a queue. This was written in by our original developers 5+ years ago and is no longer needed. You can see the popup here:

select_5F00_queue.png

Default Email Form Properties:

8228.FormProperties.png

Here is the JavaScript for new_EmailForm.js:

(function () {
var parentActivityLoaded;
var formContext;

parentActivityLoaded = function (activity) {
var fromAttribute, newValue, queueItem, queueRef;
queueItem = activity.Email_QueueItem.results[0];
queueRef = queueItem.QueueId;
newValue = {
entityType: queueRef.LogicalName,
id: queueRef.Id,
name: queueRef.Name
};
fromAttribute = formContext.getAttribute("from");
return fromAttribute.setValue([newValue]);
};

this.onLoad = function (context) {
formContext = context.getFormContext();

var fromAttribute, parentActivity, parentActivityId;
if (formContext.getAttribute("statuscode").getValue() === 1) {
parentActivity = formContext.getAttribute("parentactivityid").getValue();
if (parentActivity) {
parentActivityId = parentActivity[0].id.replace("{", "").replace("}", "");
return SDK.REST.retrieveRecord(parentActivityId, "Email", null, "Email_QueueItem", parentActivityLoaded, function () {
return Xrm.Utility.alertDialog("Failed to retrieve parent activity");
});
}
}
};

this.onSave = function (context) {
formContext = context.getFormContext();

var eventArgs, fromField;
eventArgs = context.getEventArgs();
fromField = formContext.getAttribute("from").getValue();
if (formContext.ui.getFormType() !== 4) {
if (fromField && fromField[0].entityType !== "queue") {
Xrm.Utility.alertDialog("Can't send email from users, select a queue instead");
return eventArgs.preventDefault();
}
}
};

}).call(this);

What can I change so that we can send as a user again? Let me know if I can provide anything else. Thank you! 

I have the same question (0)
  • heidis_egab Profile Picture
    5 on at

    Hi Andrew,

    Perfect, thank you! For now, I just disabled it in Events and did not change the script, just in case we want it functioning again later for some reason. It is working fine now. Again, thanks!

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I believe all you need is to deactive or remove reference to "onSave" function from your "new_EmailForm.js" webresource in "OnSave" events.

    In order to access it in "Form Properties", "Events" dropdown choose "OnSave".

  • meelamri Profile Picture
    13,216 User Group Leader on at

    Hi,

    Can you please share the onSave event handlers ? (Check in Event below Control - your screenshot 2)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 101

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 69 Super User 2025 Season 2

#3
TAHER Mehdi Profile Picture

TAHER Mehdi 58

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans