Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Customize Button to Pre-populate field

Posted on by Microsoft Employee

This might be too complex, but in my environment I have Account Types and Contact Types, I would like to customize a button to automatically populate these fields.

For example, I have two types of contacts, one is known just as "contact" and the other one is "participant". I would like to have buttons called Add Participant and Add Contact to pre-populate the field Contact Type.

Is it possible to do that through the Ribbon Workbench?

*This post is locked for comments

  • Verified answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: Customize Button to Pre-populate field

    Hi Lucas,

     have a look at the openEntityForm function - that's, likely, what you need:

    msdn.microsoft.com/.../jj602956.aspx

     If you pass null for the record id, it'll bring up a "create" form. You can pass formid through the parameters. And you can pass type value through the parameters as well.

     There are examples there, but it would look more or less like this:

    var parameters = {};

    parameters["formid"] = "<FORM ID>";

    parameters["new_contacttype"] = 100000000;

    Xrm.Utility.openEntityForm("contact", null, parameters);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Customize Button to Pre-populate field

    I see I can add the Java Script function to the button, but how do I add action to a button to call the function to create a new record (in this case a new contact) and pull up the right form and then populate the field (Contact Type)?

  • Suggested answer
    M I Mostafa Profile Picture
    M I Mostafa 4,257 on at
    RE: Customize Button to Pre-populate field

    Hi Lucas,

    You could create the two buttons so that they trigger a JavaScript function. You will have two versions of the same function to be fired based on which button is clicked. Every time either button is clicked, the relevant function will be executed to set the field value.

    Have a look at this example:

    stackoverflow.com/.../javascript-ms-dynamics-crm-2016-changing-value-of-option-set-field-using-conf

    You can add the buttons by editing the customisations ribbondiff xml easily.

    Hope this helps! Please click "yes" if you found this response helpful.

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