Knowledge found and lost while working with Microsoft Dynamics CRM
RSS icon Home icon
  • Adding a toolbar button to create new, related entities

    Posted on November 9th, 2007 Mitch Milam Print Print 17 comments

    [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.

    Customization, Dynamics CRM, Unsupported
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    5,829 views
     

    17 responses to “Adding a toolbar button to create new, related entities”

    1. [...] Read the rest of this great post here [...]

    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. Filed under: Extensibility [...]

    3. [...] 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. [...]

    4. [...] 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? [...]

    5. 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…

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

      Mitch

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

    8. Luis Fernando

      Valeu, pela ajuda…
      Muito bom este teu exemplo

    9. 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

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

    11. 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?

    12. 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

    13. 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

    14. 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

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

    16. 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.

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

    Leave a reply