Skip to main content

Posts

Showing posts from June, 2010

ForceSubmit and Default Read-Only Lookups

I made quite the discovery the other day with the ForceSubmit property.  I was writing a plugin on pre-create of an entity where I needed to grab a lookup attribute from the entity being created.  I finished the plugin and then tried testing it out.

I went to create a new record for this entity and realized that the lookup I needed to populate was set to read-only in the form customizations.  I used the IE8 dev tool bar to execute some javascript that enabled the lookup and then set the ForceSubmit property to true so it would save the value.  I then populated the lookup and created the record.

I was greeted with this infamous error:
My first instinct was that my plugin wasn't working correctly, so I set a breakpoint but it wasn't getting triggered.  I then created a record without populating this lookup and it hit my breakpoint and worked successfully.  My next thought was that maybe ForceSubmit was the culprit.  To test this theory I enabled this lookup in the form customiza…

Show Column Total from a CRM Grid

Update: Andriy a33ik Butenko pointed out that my solution won't work on all views because the specific column will probably not be in all of the views. I updated the solution to check if the column exists first, if not it will prompt the user that this functionality can't be done on the selected view.

A user on the CRM forums asked if it was possible to be able to show a column total from highlighted records in a CRM grid. I went ahead and wrote some javascript to implement this functionality. The javascript for this is fairly simple and will be executed from a button in the ISV Config for an entity grid. I will be using the native Opportunity grid and I will be calculating the Est. Revenue column from that grid.

First, we can't do this functionality if our column doesn't exist in the view, so we will create a function to check if our column exists (estimatedvalue in this case).  We will first create a function called 'doesColumnExist':

function doesColumnExist…

ForceSubmit Property

There are a lot of scenarios where you need to automatically populate a field when it is read-only or will be set read-only dynamically.  In this scenario you would want the value to be saved when the user clicks Save, but by default a field that is read-only will not submit.  To get a read-only field to submit, you can set the ForceSubmit property of the field to true using javascript:

crmForm.all.name.ForceSubmit = true;
What ForceSubmit actually does is always submit that attribute to be saved, whether or not it was actually modified on the form.  One thing to note is that if you have a plugin that is filtering on an attribute where ForceSubmit is set to true, then your plugin will always be triggered when the user saves the form.  Also if you set ForceSubmit to true on ownerid then it will always execute an Assign message whether or not the owner was actually changed.
Because of the way ForceSubmit works, the best way to use it would be to only set it if the field was actually chang…

Simple CRM Tools

A colleague of mine recently turned me onto some very useful tools that are simple and easy use. Often times as a CRM developer, we find ourselves needing either the entity type code or the GUID of the record we’re on.  We can easily obtain this information by creating a bookmark that displays either the GUID or the entity type code, directly from the form we’re on.  As an added benefit, we can also set the values to our clipboard so they can be pasted as needed.

To create these bookmarks, just browse to any CRM page and add it to your favorites.  Then, you can edit the bookmark and set the URL to the javascript you would like executed.


Here's the javascript to do so:


Entity Type Code:
javascript:if (crmForm.ObjectTypeCode){clipboardData.setData("Text", crmForm.ObjectTypeCode.toString()); alert(crmForm.ObjectTypeCode);}
Entity ID:
javascript:if (crmForm.ObjectId){clipboardData.setData("Text", crmForm.ObjectId.toString()); alert(crmForm.ObjectId);} else { alert('…