Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

Remove Send from Queue Only - Custom Form

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! 

  • heidis_egab Profile Picture
    heidis_egab 5 on at
    RE: Remove Send from Queue Only - Custom Form

    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
    a33ik 84,321 Most Valuable Professional on at
    RE: Remove Send from Queue Only - Custom Form

    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
    meelamri 13,198 User Group Leader on at
    RE: Remove Send from Queue Only - Custom Form

    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

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,647 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans