I’m trying to give users two UI only lookup fields which they can choose records from. Then, I will send those records to Apex to do further processing.
However, 90% of the time, these lookup fields can be predictably populated. So I’m trying to automate the population of the fields. Therefore, I’m using custom snippet rendering to render the UI only reference fields. However, once rendered with the Id I want, they only show the Id and not the name of the record even though the field.options.template defaults to “{{Name}}” according to documentation (http://help.skuid.com/m/11720/l/214147-skuid-ui-field-renderers - REFERENCE Edit method).
Additionally, once I click out of the field after the field is rendered the Id’s disappear.
Is there a method in my snippet I’m missing?
Here’s my snippet:
var field = arguments[0]; //field objectvar fieldValue = arguments[1]; //null in the beginning since it’s not populated till end of this script
var RecentlyFundedOppModel = skuid.model.getModel(‘RecentlyFundedOpp’); //get the model I want to populate the id from
var RecentlyFundedOppFirstRow = RecentlyFundedOppModel.getFirstRow(); //the model only has one row, so get that row from the model
var RecentlyFundedOppFirstRowId = RecentlyFundedOppModel.getFieldValue(RecentlyFundedOppFirstRow, ‘Id’); //get the id from the row to feed to the field value
skuid.ui.fieldRenderers.REFERENCE.edit(field, RecentlyFundedOppFirstRowId); //populate the UI only referencefield with the id from above
See the gif for what happens when I click away from the lookup field after it’s been populated