I have a lookup field on a form which normally displays the primary key associated with the other entity. Looking for a way to display an alternate field from the other entity that holds after Save without affecting Save & Close expected functionality.
Example
-Entity called Outcome has a lookup field to an entity called Individual Service - lookup field is called dhsive_individualservice
Then in the Individual Service entity, primary key in this example is IS-1001 and there is a Service Start Date field - dhsive_servicestartdate
Looking for a good way for the form associated with the Outcome entity to display an alternate field in the lookup.....something like below or similar....where dhsive_servicestartdate would display instead of the primary key field
I can achieve this for an onLoad event on the Outcome entity/form by doing something similar to below:
-Do an HTTPRequest/JSON to get the associated field values in the Individual Service entity
var v = _formContext.getAttribute("dhsive_individualservice").getValue(); //lookup field on Outcome associated with Individual Service
v[0].name = results.value[0]["dhsive_servicestartdate"]; //Get the desired alternate field from the associated lookup entity
_formContext.getAttribute("dhsive_individualservice").setValue(v); //Set the lookup field on Outcome to show the alternate field
This type of approach seems to work well for onLoad, but of course after saving, the lookup field defaults back to the value from the primary key in the associated entity.
If trying something like forcing a page refresh after Save, it works but then Save and Close doesn't work as expected as the refresh happens before closing.
Is there some type of approach which would allow to see the alternate field in the lookup after Save and also allow Save & Close to still work as expected?