Update Optionset Values in Header

CRM 2013 allows us to have updateable fields in the header.  Great!  One thing I’ve wanted in a number of scenarios is an updatable Status Reason field up there.  So today I was rolling out a form that one user type will submit, and another user type will approve.  They will do this by setting the Status Reason field.  The submitting users would not have access to the “Approve” status reason so they can’t approve their own records.  I had some checks to make sure the user had the right permissions with code on submit, but what I really wanted was to remove the selections from the drop down onload.

OK, normally this is no problem.  You can use the Xrm.Page.getControl(“statuscode”).removeOption(<optionsetvalue>) method to remove the value.  The only problem is, this doesn’t actually remove it from the field in the header.  It only works on controls in the main form area.  Shit.  So now what?

Well I stuck some code in that looped through all the controls and alerted the names and found that it was returning a control named “header_statuscode”!  I added Xrm.Page.getControl(“header_statuscode”).removeOption(value) to my onload script and Wahlah!   The option I wanted out of the UI was gone in the header control.

I haven’t found any documentation on the “header_” prefix in the Microsoft SDK, but this seems to work fine using the Xrm.Page methods, so I don’t know if this is an oversight on their part or if this customization would be “unsupported”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: