RE: Pull data from related entity onLoad javscript
Hey,
To read the details of related entity from the lookup value follow the below steps
1. On entity B form "OnLoad" script read the lookup value.
var entitiyALookup = Xrm.Page.data.entity.getAttributes.('LookUpSchemaName').getValue()
if(entitiyALookup != null && entitiyALookup.length[0]){
var entityARecordId = entitiyALookup[0].id
var entityARecordType = entitiyALookup[0].entityType
}
2. Now make a web API call to get the field value (in your case the optionset field value ) from entity A record.
Xrm.WebApi.retrieveRecord(entityARecordType, entityARecordId).then(function(result){
console.log(result);
//Here you can read the field data from entity A. i.e., the optionset field value
}, function(error){ console.log(error); alert(error)});
Note: Xrm.WebApi.retrieveRecord method is only for dynamics 365 v9.0. If you are running any old version of CRM then make use of AJAX to consume the webapi.
Thanks
Nitin