Welcome to big CRM stylin’!

Here you will find the latest information regarding Microsoft Dynamics CRM and occasionally other Dynamics solutions.

The focus is on general news and tips for the intrepid CRM Administrator, as well as something for even the newest CRM user.

How to add a button to an entity form that automatically creates a new related CRM record

You know your users want to push your buttons.

You know your users want to push your buttons.

Microsoft Dynamics CRM 4.0 is already user friendly and intuitive.  However, there will be times where you want to nudge the CRM users along the road to productivity by providing a nice shiny button that does what they want.  In this case I want to add a button to a custom entity form, where upon clicking would automatically pop open a new related record.  

 A couple potential  case examples off the top of my head:  

  • Button to create a new Phone Call activity, related to an open custom entity record.
  • Button to create a new Contact record, related to an open Account record.

Since the button can run JavaScript on demand, you can think outside the box and consider other unique scenarios and possibilities.  

See below for the general procedure to get this published.  I’ll try to make it quick and painless.  

Customize your ISV.config file  

All Dynamics CRM deployments include a default ISV Config file.  However, this default file is typically riddled with developer test examples that can clutter your CRM if you’re not mindful.  On the other hand, it may serve as a useful reference to see some customization possbilities.   

If you want a clean ISV Config file with the button I’m creating, I’ve provided a copy here to download.  It’s up to you! 

ISV-button-template.zip  

To export or back up your current ISV Config file:   

  1. Navigate to Settings > Customization > Export Customizations.
  2. Export the ISV file to your desktop or local drive.
Exporting your ISV Config file

Exporting your ISV Config file

  Use your favorite XML or text editor program to view and edit your ISV customization file.  I particularly like the free Microsoft XML Notepad 2007 and Notepad ++. The code you want to add will look something like the below, nested in the Entities section. 

      <Entities>
        <Entity name=”new_customentity”>
          <ToolBar ValidForCreate=”0″ ValidForUpdate=”1″>
            <ToolBarSpacer></ToolBarSpacer>
            <Button Icon=”/_imgs/ico_18_debug.gif” JavaScript=”locAddRelatedTo(10016);”>
              <Titles>
                <Title LCID=”1033″ Text=”Create a new related record” />
              </Titles>
              <ToolTips>
                <ToolTip LCID=”1033″ Text=”Create a new related record based on this open record.” />
              </ToolTips>
            </Button>
            <ToolBarSpacer />
          </ToolBar>
        </Entity>
      </Entities>
 

  In the above code, we: 

  • Referenced where we want this button with the Entity name value.
  • Made this button available only when a record is saved by disabling ValidForCreate and enabling ValidForUpdate.
  • Added a couple ToolBarSpacer spots for neatness.
  • Referenced a icon for it at the Button Icon value.  The debug icon works for me.
  • Added Title and ToolTip info to let the users know what it does.
  • Added a simple JavaScript line to create a new related record.

To make this JavaScript work for you, you’ll need to find out the related entity’s “Object Type Code”.  It’s really easy.  Simply browse to your CRM deployment’s Metadata Browser, which is typically at this URL format: 

http://{CRM_URL}/{Organization_Name}/sdk/list.aspx

Click on the related entity’s details, and you should see “Object Type Code” number.  Insert that number in the parenthesis for this JavaScript snippet:

locAddRelatedTo({Object_Type_Code})

Follow me here: the locAddRelatedTo function will let the button open a new related CRM record of the entity I specified with the Object Type Code.  Simple as that.

 Once you finished customizing your new ISV Config file, make sure you upload it back to your CRM deployment. 

Last Step!  Enable custom menus and toolbars

If you published your new ISV config file and you still don’t see the changes, this is the reason.

By default, CRM disables the custom menus and toolbars.  This means CRM will simply ignore whatever ISV Config file is out there.

To enable your custom button:  

  • Navigate to Settings > Administration> System Settings.
  • Click on the Customization tab.
  • Add the Clients where you want this customization to appear.  The choices?  Web, Outlook, and Outlook Offline.
Custom Menu Settings

Custom Menu Settings

  Thanks to Mitch Milam’s blog for pointing me in the right direction.  

4 comments to How to add a button to an entity form that automatically creates a new related CRM record

  • Peter

    The regarding does not populate if it is a phone call for instance

  • You’re correct, the JavaScript I provided creates a new phone call record but doesn’t populate the “Regarding” field. I haven’t tested that script with all of the CRM system entities yet.

    I know it works 100% of the time between custom entities.

    Thanks for the feedback Peter!

  • Jasper

    You can use locAddActTo(4210)instead of locAddRelatedTo(10016) if you want to add an activity(phonecall) instead of a custom entity.

    Thanks for the great blog post by the way.

  • Thanks for the tip and comment, Jasper!

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>