Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Email Activity From Parameter: By default set to Queue

Posted on by 160

Hi Guys,

I have a requirement to set Email Activity From parameter as particular Queue. 

When ever I create a new Email activity from CRM the from parameter should be automatically set as "Support". Currently it gets populated as the user who has logged in to CRM.

EmailFromParameter.PNG

Can anyone suggest any solution for it.

*This post is locked for comments

  • Krishna Bhanushali Profile Picture
    Krishna Bhanushali 160 on at
    RE: Email Activity From Parameter: By default set to Queue

    var onLoad = function () {

           "use strict";

           debugger;

           /// <summary>

           /// Set contact field required

           /// Set Product and Version field not required on create

           /// </summary>

           var fromParameterCtrl = null;

           var statusCodeCtrl = null;

           var statusCodeAttr = null;

           var statusCodeAttrValue = null;

           statusCodeCtrl = Xrm.Page.getControl(constants.statuscode);

           fromParameterCtrl = Xrm.Page.getControl(constants.fromParameter);

           if (statusCodeCtrl) {

               statusCodeAttr = Xrm.Page.getAttribute(constants.statuscode)

               if (statusCodeAttr != null) {

                   statusCodeAttrValue = statusCodeAttr.getValue();

                   var fromparameter=Xrm.Page.getAttribute(constants.fromParameter).getValue();

                   var id = fromparameter[0].id.replace("{", "").replace("}", "");

                   if (id === "3fea92bc-9496-e611-80e8-c4346bac3908" || id === "3FEA92BC-9496-E611-80E8-C4346BAC3908") {

                       return;

                   }

                   //// Check if status of Email is Draft or not.

                   //// If Draft, set From Parameter as "Support Queue"

                   if (statusCodeAttrValue === 1) {

                       if (fromParameterCtrl) {

                           //// Fetch the Support Queue and set on From parameter

                           fetchSupportQueue();

                       }

                       else {

                           Xrm.Utility.alertDialog("From parameter control is not found");

                       }

                   }

               }

           }

       };

    var onSuccessCallbackSupportQueue = function (data) {

           "use strict";

           if (data && data.value.length > 0) {

               var partlistData = new Array();

               partlistData[0] = new Object();

               partlistData[0].id = data.value[0].queueid;

               partlistData[0].name = data.value[0].name;

               partlistData[0].entityType = constants.entityTypeQueue;

               Xrm.Page.getAttribute(constants.fromParameter).setValue(partlistData);

               Xrm.Page.getAttribute(constants.fromParameter).setSubmitMode();

               //Xrm.Page.data.entity.save(null);

           }

           else {

               Xrm.Utility.alertDialog(errorMessage.Support_Queue_not_found);

           }

       };

    The onLoad function is called on form Load. fetchSupportQueue function basically calls the Retrieve function for Support Queue User.

  • Marc G. Profile Picture
    Marc G. 895 on at
    RE: Email Activity From Parameter: By default set to Queue

    Can you post your JavaScript here? Than we'll be having a look :-)

  • Krishna Bhanushali Profile Picture
    Krishna Bhanushali 160 on at
    RE: Email Activity From Parameter: By default set to Queue

    The error is below:

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Cannot update subject or description unless email is in draft statusDetail:

    <OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance&quot; xmlns="schemas.microsoft.com/.../Contracts&quot;>

     <ActivityId>27eb3ec2-ef7a-461c-b7aa-6cbfe95fbd4c</ActivityId>

     <ErrorCode>-2147187962</ErrorCode>

     <ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic&quot; />

     <Message>Cannot update subject or description unless email is in draft status</Message>

     <Timestamp>2017-04-20T05:34:03.9223006Z</Timestamp>

     <ExceptionSource i:nil="true" />

     <InnerFault i:nil="true" />

     <OriginalException i:nil="true" />

     <TraceText i:nil="true" />

    </OrganizationServiceFault>

  • Krishna Bhanushali Profile Picture
    Krishna Bhanushali 160 on at
    RE: Email Activity From Parameter: By default set to Queue

    Hi,

    JavaScript worked for me but while I click on the Send button, the email is send but I receive and error "Access is denied: Cannot update subject or description unless email is in draft"

    I need to solve this error. I have checked removing the JavaScript function and everything works fine.

  • Suggested answer
    Mihir Maruti Kadam Profile Picture
    Mihir Maruti Kadam 700 on at
    RE: Email Activity From Parameter: By default set to Queue

    No. You have to use JS.

  • Krishna Bhanushali Profile Picture
    Krishna Bhanushali 160 on at
    RE: Email Activity From Parameter: By default set to Queue

    When we reply an email activity in CRM can this be achievable?

  • Verified answer
    Mihir Maruti Kadam Profile Picture
    Mihir Maruti Kadam 700 on at
    RE: Email Activity From Parameter: By default set to Queue

    Hi Krishna,

    You have only one option to set "From" parameter on a load of form. Fetch data from CRM using web API and set 'From' parameter using JS.

    Another option is there, but it will not work for "From " and "To" field. Set value functionality in the business rule will not function in this fields.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Email Activity From Parameter: By default set to Queue

    You will have to write JavaScript for it as this cannot be done by Business rule.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans