[Bug] setDefaultView is not working in the Unified Interface

Recently, there is an issue in Unified Interface where setDefaultView Client API in JavaScript is not working even though the same script is working for the same form in the legacy web client.

formContext.getControl("parentaccountid").setDefaultView("{00000000-0000-0000-00AA-000010001031}"); // GUID of Inactive Accounts view

After raising a ticket with Microsoft, the issue had been concluded as a product bug by the “Product Team” and the following workaround solution is provided.

A possible workaround is to reset the Lookup's state by removing it from the form then re-adding it to the form. Note that clicking the "OK" button on the Field Properties popup will put Lookup back into the "bad" state.

There is no expected ETA on this bug, so if you ever encounter the same issue on the unified interface, remove the lookup control and re-add it back to solve. You won't be able to change the Field Properties or else, it would add the highlighted components in the form XML which would make the lookup control into so-called "bad state" and stop setDefaultView working.

 <control id="parentaccountid" classid="{270BD3DB-D9AF-4782-9025-509E298DEC0A}" datafieldname="parentaccountid" disabled="false" uniqueid="{ce130ea5-0e7b-2ca7-a144-59eb06ac8911}">  
  <parameters>  
      <AutoResolve>true</AutoResolve>  
      <DisableMru>false</DisableMru>  
      <DisableQuickFind>false</DisableQuickFind>  
      <DisableViewPicker>false</DisableViewPicker>  
      <DefaultViewId>{A9AF0AB8-861D-4CFA-92A5-C6281FED7FAB}</DefaultViewId>  
      <AllowFilterOff>false</AllowFilterOff>  
  </parameters>  
 </control>  

So if you really have to change the lookup control properties and still want to make setDefaultView work on Unified Interface but really cannot wait for the fix from the product team, you may play around with the formxml and add/remove one of the highlighted components to find out which on is causing the issue.

Comments

Popular Posts