Skip to main content

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 customizations and tried again and it worked successfully.

In conclusion, if you make a lookup read-only using custom javascript, you can then set ForceSubmit to true on the lookup to save the value as needed.  On the other hand, if you default the lookup to read-only in the form customizations then you will not be able to set ForceSubmit to true to save the value.


Popular posts from this blog

Announcing the New Dynamics 365 Toolbot Chrome Extension!

Today I am excited to announce the new Dynamics 365 Toolbot! This new Chrome Extension will allow you to perform commands that will help you with your development or administrative tasks. The extension can be found here -

Note: Currently, due to the APIs being used, it only works on v9+.

First, navigate to the link above using Chrome and install the extension. Then, head to your Dynamics 365 environment and open a record. From there, click the little blue robot icon in the toolbar of Chrome which will pop open the Toolbot.

Click the text box and a list of commands will display. You can select or type any of the commands and hit Submit to execute them. Some commands require you to replace the default token with the desired request.

For example, select or type "display id" and click Submit and the Toolbot will display the current record's ID.

The majority of the commands should …

Dynamics 365 ToolBot: Auto-populate the form

Today I released a new command for the Dynamics 365 ToolBot that I am really excited about! If you're not sure what the Dynamics 365 ToolBot is, it is a new Chrome extension that I released recently that allows you to quickly execute helpful commands for administrators, developers and testers.

This new command, called "Fill Form", will automatically populate all the fields on the form with random data. As a developer, I always need test data and I am the worst at coming up with fake data to use. With this command, you can navigate to any record, open the ToolBot, type "Fill Form" and your record will instantly be populated with random data so you can quickly save the record and proceed with your testing.

A few things to note about this command:
It attempts to detect contact fields (based on the field name) such as first name, last name, email, phone and address and populate those fields with realistic fake dataAny other field will generate random data based on t…

CRM 2011 LINQ - All Columns vs. Selected Columns

When creating LINQ queries in CRM 2011, it is easy enough to return the whole column set of the entity record without even thinking about the impact.  
Below is an example of querying all contacts from Chicago and returning all columns for each contact record.

This can be a big performance impact depending on the amount of columns that exist on the Contact entity and how many contact records exist in the system.  Another issue is that it could cause errors down the line if some of the attribute types are changed in the CRM system since the data is being bound to a model class that could be out-of-sync.
From the MSDN article on constructing LINQ queries (, we can see that the select clause creates a column set:
The select clause defines the form of the data returned. The clause creates a column set based on the query expression results. You can also define an instance of a new object to work with. The newly created object using the…