Open jordimontana82 opened 7 months ago
@jordimontana82 Yes does sound like a server side issue, however I am not following the Mix of EntityCollection vs entity logical name in this context.
The SDK Client only uses EntityLogicalName. EntitySETName is used in the web API ( though it is often confused with EntityCollectionName )
Could you provide a snipet that causes the error?
thanks mattB
RE:
If I send a CreateMultipleRequest or UpsertMultipleRequest where some of the entity records have a different logical name than the EntityName that was set in the EntityCollection, it throws a ErrorCodes.InvalidArgument FaultException making this error quite obvious.
All the records in the collection must be the same type. See Use bulk operation messages
CreateMultiple: Creates multiple records of the same type in a single request. UpdateMultiple: Updates multiple records of the same type in a single request. UpsertMultiple: Creates or updates multiple records of the same type in a single request.
@MattB-msft it's the difference between the logical name in the main entity collection vs each Logical Name on each Entity record from the list. Here is an example that passes a list with a single a custom entity (dv_test) when the main EntityName is account. It seems the CreateMultiple and UpsertMultiple messages check this scenario on server side, but the UpdateMultiple doesn't.
[Fact]
public void Should_throw_exception_if_update_multiple_is_called_with_an_entity_record_with_a_logical_name_different_than_the_main_logical_name()
{
var guid1 = _service.Create(new dv_test());
List<Entity> recordsToUpdate = new List<Entity>()
{
new dv_test() { Id = guid1 }
};
var entities = new EntityCollection(recordsToUpdate)
{
EntityName = Account.EntityLogicalName
};
var request = new UpdateMultipleRequest()
{
Targets = entities
};
var ex = XAssert.ThrowsFaultCode(ErrorCodes.QueryBuilderNoAttribute, () => _service.Execute(request));
Assert.StartsWith($"'{dv_test.EntityLogicalName}' entity doesn't contain attribute with Name = 'address1_line1' and NameMapping = 'Platform'", ex.Detail.Message);
}
RE:
If I send a CreateMultipleRequest or UpsertMultipleRequest where some of the entity records have a different logical name than the EntityName that was set in the EntityCollection, it throws a ErrorCodes.InvalidArgument FaultException making this error quite obvious.
All the records in the collection must be the same type. See Use bulk operation messages
CreateMultiple: Creates multiple records of the same type in a single request. UpdateMultiple: Updates multiple records of the same type in a single request. UpsertMultiple: Creates or updates multiple records of the same type in a single request.
Thanks @JimDaly , I did check the docs, was just trying to reproduce different edge cases for each message in FakeXrmEasy :)
This cosmetic error probably belongs to the platform rather than the client but dunno where else to raise it.
If I send a CreateMultipleRequest or UpsertMultipleRequest where some of the entity records have a different logical name than the EntityName that was set in the EntityCollection, it throws a ErrorCodes.InvalidArgument FaultException making this error quite obvious.
However if we try to reproduce the same scenario with UpdateMultipleRequest, the platform in this case returns an ErrorCodes.QueryBuilderNoAttribute FaultException with an error along the lines of " entity doesn't contain attribute with Name = 'address1_line1' and NameMapping = 'Platform'".
The difference is just purely cosmetic but it might let someone think that some attributes are missing when in fact the EntityName of the EntityCollection was different. : D