RE: how to collect value from javascript when fields present on form from other entity
After working with MS support they provided the code that should work for PCF Form Component:
//this value defines if the control was already loaded. I added a 1 because I have the field twice in the form
var wasContentLoaded = formContext.getControl("regardingobjectid1").isLoaded();
if (wasContentLoaded && formContext.getControl("regardingobjectid1").data.getIsDirty())
{
// if any field of the form component got updated
var object = new Array();
object[0] = new Object();
object[0].id = formContext.data.entity.getId();
object[0].name = formContext.data.entity.getPrimaryAttributeValue();
object[0].entityType = formContext.data.entity.getEntityName();
formContext.getControl("regardingobjectid1").data.entity.attributes.get("cus_phonecall").setValue(object);
}
In this example I am updating the cus_phonecall field from the related entity.
This is working fine in my environments.
I hope this helps!!
Best,