Knowledge found and lost while working with Microsoft Dynamics CRM
RSS icon Home icon
  • Calling a custom JavaScript function from a custom toolbar button

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

    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?

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

    <Button
        Title="DoIt"
        ToolTip="Do something interesting"
        Icon="/_imgs/ico_16_1071.gif"
        JavaScript="MyCustomFunction();"
    />

    Inside the Form's OnLoad event, we declare our MyCustomFunction() like this:

       1: MyCustomFunction = function()
       2: {
       3:  alert("we're doing something interesting here...");
       4: }

     

    By adding the function to the OnLoad event, you centralize your JavaScript functions which will usually decrease your maintenance requirements since all of the code is in one place. Also, since we're working inside the form, we have access to the Form's attributes as we normally would.

    Customization, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    2,811 views
  • 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