In my model-driven app, I have a form for a custom entity that has a lookup field and the owner field on it. When adding a new record, the owner defaults to the current user. When a value is selected in the lookup field, I'm trying to get the owner value from the selected lookup value and set the owner of the record I'm adding to that value. If the owner value is a User, it works fine. But when the owner is a Team, I get the following error:
Uncaught (in promise) UciError: Value should be of type: entityType: Parameter Name: value[0].entityType
Here is my code that's executed in the onChange JavaScript event (with variable values hardcoded so you can see what they are):
ownerId = "cec4bd48-df38-eb11-a813-000d3a531257";
teamName = "Child Business Unit 1";
entityType = "team";
var lookupData = new Array();
var lookupItem = new Object();
lookupItem.id = ownerId;
lookupItem.name = teamName;
lookupItem.entityType = entityType;
lookupData[0] = lookupItem;
var fieldOwner = formContext.getAttribute("ownerid");
fieldOwner.setValue(lookupData);
I also noticed that on the UI, if I click in the owner field, I can only search for users. But using the Assign feature, I can assign it to this Team. Is there another setting that I need to change to be able to set it to a Team in Javascript?