Sometimes it is useful, sometimes it is not…when you create a new custom entity in Microsoft CRM, there is always one default field called ‘name’ which is a varchar field.
One will say that you can always make it ‘non-mandatory’ and remove it from the form, but the problem lies in the search view, where you will not be able to remove it!
So here is a quick tip for those of you who want to keep this field in the default views but not on the form, by hiding it; the idea is very simple: suppose you have a picklist on the form, you can always retrieve it’s text to fill the ‘name’ field, therefore the text will be displayed in all the default views!
Here is an explanation of the example below: the new entity is used to track all the contacts’ income revenues, with the amount (money field) and the type of revenue (picklist).
- Create a new entity called ‘Income revenues’, with ‘User’ ownership
- Modify the default attribute label from ‘Name’ to ‘Revenue type’
- Change its required level to ‘No constraint’
- Save the new entity
- Create a new attribute
- Call it ‘Revenue type’
- Choose the picklist field type and add the appropriate values
- Change its required level to either ‘Required’ or ‘Recommended’
- On the default form:
- Place the revenue type textbox next to the revenue type picklist
- Disable the revenue type textbox
- In the form properties, place this code in the OnLoad event
/*hide field only*/ crmForm.all.new_revenuetypetextfield.style.display = 'none';
- In the picklist properties, place this code in the OnChange event
if (crmForm.all.new_revenuetypelist != null) { crmForm.all.new_revenuetypetextfield.DataValue = crmForm.all.new_revenuetypelist.SelectedText; } else { crmForm.all.new_revenuetypetextfield.DataValue = ""; } crmForm.all.new_revenuetypetextfield.ForceSubmit = true;
- Save & test your form before publishing… if everything looks good, you’re all set!