Hello, I have a problem with the ID of an aggregate.
I explain:
I have an aggregate that is used to save the information of a contract, an attribute appears in it to save a company:
The attribute is company
When I perform the client action, with the rest of the Id's everything works correctly, and saves all the information correctly, but when I save with ID = 1 in the DB it saves it as a null identifier. This ID is collected from another aggregate that stores information related to the user. Therefore, the way the client action works is that when a contract is created from scratch, by default the aggregate of the contract is updated with that user data.
At this point, the id in the aggregate has been updated to the default value:
But when I click on the save button the attribute value has become null
After this, as I saw that it was not saving the value, I decided to try forcing it to collect the value just before creating the contract.
When it reaches the server action, the data that the action receives is well updated:
But when the data in the DB is updated... surprise, the companyID value is null.
I've been looking for any errors in the code for 3 days, and looking at forums and I can't find a reason why it doesn't save the information well. As I already said, if the default company ID is different from 1, the attribute is saved well.
I don't immediately see something wrong here. Couple of questions:
- What delete rule do you use for the Contract.Company attribute?- What does the ContractCreateOrUpdate look like? Does it perform any data manipulation before storing it in the database? Does it contain any exception handling?
- The delete rule is ignore
- No, no value of the contract is modified, the id of the contract that has been created is simply collected to update the aggregate and display the information
The problem is that with id =1 the company id is not saved correctly, but then we have more companies in the company table and with any other id, everything is saved correctly
Check in Company Entity is there any record with Id "1".
If there is no record with id = 1 in company table then you are inserting non-existing reference id, so the company attribute value will be zero.
If there is a record in company table where id = 1, then share your Oml i will go through your logic to find the error.
Note: In assign node for company attributes you are send a partnerId, please make share sure it's a proper reference id.
If there is no Company record with Id 1 that would normally result in a foreign key exception and a rollback of the transaction instead of the field being set to zero.
Yes Jerson you right i know that it's my mistake sorry for Misleading , i am saying make sure there is a record in the company entity with id =1 .
David Béjar
check "Create or update" server action make sure all values you are sending to "create or update" Cred operation is correct.