[unsupported]

One of my current projects has requirements to add toolbar buttons to allow the user to create a new, related Entity such as a phone call or appointment with a click of a button.

Buttons are added to the toolbar by modifying the isv.config.xml and inserting code similar to the following:

<Button
    Title="Phone Call"
    ToolTip="Create a phone call"
    Icon="/_imgs/ico_16_1071.gif"
    JavaScript="locAddRelatedTo(4210);"
/>

I would like to point out the JavaScript function locAddRelatedTo().  This will open a new window containing a new CRM Entity.  The Entity being created is determined by the parameter passed to the function.  The parameter is the ID of the Entity in question.  In the above example, 4210 is the Entity ID for the Phone Call Activity.  Substitute any valid Entity ID to create a new built-in or custom Entity.

 

18 Responses to Adding a toolbar button to create new, related entities

  1. [...] CRM MVP Mitch Milam blogs about "Adding a toolbar button to create new related entities". One of the very popular features of the Microsoft Dynamics CRM platform is the extensibility support built into the product. Mitch's blog demonstrates that customization doesn't have to be hard. Filed under: Extensibility [...]

  2. [...] CRM MVP Mitch Milam blogs about "Adding a toolbar button to create new related entities". One of the very popular features of the Microsoft Dynamics CRM platform is the extensibility support built into the product. Mitch's blog demonstrates that customization doesn't have to be hard. [...]

  3. [...] Speaking of toolbar buttons.  Another common practice is to add a toolbar button that will perform some complex operation in JavaScript.  Since you generally don't want the JavaScript itself inside your isv.config.xml file, you need a place to put it where it's easily maintained.  How about in the Form's OnLoad event? [...]

  4. mwittemann says:

    Mitch, one weird thing I've found when adding these buttons is that the exact function to call can sometimes be less than intuitive. For example, if you want to add an activity to an opportunity, and you want the activity's "Regarding" field to be pre-populated with the Opportunity, you need to call the locAddActTo(4210) function. You would think the locAddRelatedTo() function would make it related to the parent object, but it doesn't seem to work that way…

  5. mitch says:

    That is a great point Matt and not one I'm sure I have an answer for.

    Mitch

  6. Ibrahim says:

    Mitch, Awesome post. I have same project regarding same needs (buttons on top).

  7. Luis Fernando says:

    Valeu, pela ajuda…
    Muito bom este teu exemplo

  8. Sarah says:

    I need to add a phone call button in CRM 4.0. Please can you tell me if this works for CRM 4.0 and if this is the best way.

    Thanks
    Sarah

  9. mitch says:

    It should work, but I'd have to try it to be sure. I'll try and do that next week sometime.

  10. Jordan says:

    I am brand new to CRM.

    I tried this in 4.0 and I cannot get it to work. Did you get a chance to test it?

    Where does one find these functions?

  11. mitch says:

    Jordan,

    It is not the function that is incorrect, it is the parameters on the Button that are different from CRM 3.0 and 4.0. Look in the SDK for the Button element and see how Titles and Tooltips are now handled.

    Mitch

  12. Jordan says:

    Mitch,

    I set it up like the button examples in the ISVConfig:

    and the page loads with an error and the button does not work. If I change the javascript to:

    JavaScript="alert('Go to New Activity > Phone Call ');"

    It works as expected.

    Ideas?

    Jordan

  13. Jordan says:

    Mitch, I think I discovered my problem.

    I am not intending to relate the call to anything. I just want to create a new call. Where do I find the function for that?

    Jordan

  14. [...] Thanks to Mitch Milam's blog for pointing me in the right direction.   February 25th, 2010 | Tags: button, CRM 4.0, ISV, [...]

  15. KSingh says:

    Is it possible to use the same approach i.e. Button & Javascript to detect the record Id and type of record selected by the user?

    Such as when you select a single Lead record row from the Lead search view.

  16. mitch says:

    Yes. Look in the CRM SDK and you'll see some sample code on how to work with record IDs from grids.

  17. sander says:

    Thanks a lot for your post!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>