Monday, 10 September 2012

Filtered CRM LookUp Fields in style

 
 

Backround:

I had a crazy requirement on how the lookup value need to be selected, this included a lot of business rules and filtering. I chose to go the custom page route, two fields which are looksups and are dependant on each other. Financial Year determines the values for Business Unit

Details:
I used a custom aspx page that accepts Financial Year ID and Business Unit ID from the crm form- lookup fields hidden on the form. if the Ids are recieved then this is an exisiting record then i set the values on my custom page to wat is recieved from query string. I also read values that could be selected depending on the business rules. for axample only future financial years could be selected.

If querystring is empty I then just fill my dropdown with possible values. If the financial year is seleccted I fill in my business Unit dropdown with treeview that is built to easily allow the user to select the right Business Unit they belong to/want to work with. I then put the lookup image next to the treeview-embeded dropdown so that a user can click to pop open the actual crm entity we are looking up. the highlighted rows on the screenshop above is my custom page in an IFrame.  these controls are Telerik controls.

I then read the values from the iframeon the onsave event,

var fycontrol = crmForm.all.IFRAME_FY.contentWindow.document.getElementsByName("hfSelectedFYId")[0];
var bucontrol = crmForm.all.IFRAME_FY.contentWindow.document.getElementsByName("hfSelectedBU")[0];

I check if these are set. if not I cancel the saving event as these two fields are Business Required.

Happy Coding!

No comments:

Post a Comment