Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Button to open an email with pre-populated look up fields

Posted on by 20

Hi, I'm new to CRM customization and JavaScript, and am hoping I could get some help from experts here:

The goal here is to:

1. Have a button on a form of the Ticket entity. 

2. When the button is clicked from a ticket, a new Email form will show up in a new window with pre-populated fields including 'From', 'To', 'Regarding', and 'Description'

3. In the new email form - 'To' refers to the customer; 'Regarding' refers to the ticket title; 'Description' needs to include a default email template; all fields except 'Description' are look up fields.

4. the form should look like below:

7534.123.JPG

I've found various articles online and this seems to match my goal the most -  https://community.dynamics.com/crm/f/117/t/273017

I've also created a customized button and was able to publish my first Jscript passing string values from the Ticket entity.  However, I'm having trouble populating all the look up fields and inserting an email template (To, Regarding, Description); The syntax I'm using is Xrm.Utility.openEntityForm(name,id,parameters,windowOptions) and below is what I've had so far:

function CreateNewEmail()
{
//Get lookup value from Form to open the entity form
var regarding = Xrm.Page.data.entity.attributes.get("title").getValue();
var regarding = Xrm.Page.data.entity.attributes.get("incidentid").getValue(); // this line seems incorrect?

//Open a new window
var windowOptions = {
openInNewWindow: true
};

//Pass paramenters
var parameters = {};
parameters["subject"] = regarding;
parameters["formid"] ="000AA4A1-11AA-1234-ABCD-12345678ABCD";
parameters["regardingobjectid"] = regardingobjectid; // this line seems incorrect?

Xrm.Utility.openEntityForm("email", null, parameters, windowOptions);
}

 

Also, if I click an existing ticket - go to timeline - click Activities tab and select 'E-mail', then the page would go to an email form with the all the pre-populated fields I'm looking for; however I would need the email form to show up in a new window and it seems like the timeline tab is an OOB feature and thus I am not sure if I could customize this part of the form?

One last thing - not sure if there is a better way to open a new email form in a new window rather than clicking a customized bottom on a ticket form.  Any recommendation is welcome.  Thank you all in advance :)

*This post is locked for comments

  • Suggested answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Button to open an email with pre-populated look up fields

    Hi Kole Huang,

    I have tried same approach on CRM online and unfortunately using js its not working. I would suggest you to open email record with the help of JS and custom action.  

  • Suggested answer
    RE: Button to open an email with pre-populated look up fields

    Try:

    parameters["regardingobjectid"] = Guid of that ticket;

    parameters["regardingobjectidname"] = Name of that ticket;

    parameters["regardingobjectidtype"] = entity name of ticket;

    Additionally, if you're on v9.X, try out the new libraries. https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation/openform

    If helpful please marked as verified answer. 

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans