Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slightly different validation error between CreateMultipleRequest and UpdateMultipleRequest #437

Open
jordimontana82 opened this issue Mar 15, 2024 · 4 comments

Comments

@jordimontana82
Copy link

jordimontana82 commented Mar 15, 2024

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

@MattB-msft
Copy link
Member

@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. Entity**SET**Name is used in the web API ( though it is often confused with EntityCollectionName )

Could you provide a snipet that causes the error?

thanks
mattB

@JimDaly
Copy link
Member

JimDaly commented Mar 26, 2024

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.

@jordimontana82
Copy link
Author

jordimontana82 commented Mar 26, 2024

@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);
        }

@jordimontana82
Copy link
Author

jordimontana82 commented Mar 26, 2024

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants