Arun Vinoth @ Dynamics

Arun Vinoth @ Dynamics

https://arundynamix.blogspot.com

Can I create an INACTIVE record?

Published

As usual, this blogpost also originated from my learning/research/answer to a Stack overfow question :)


Often times, necessity comes and expect us to create an INACTIVE record in system. In such scenarios, we have to create the record in ACTIVE status and update it to INACTIVE in another update transaction.

Unfortunately we cannot create the INACTIVE record in one shot, it requires two DB transactions. One to create ACTIVE record and second one to deactivate it. This is by design. 

Why is this needed? 

Since the StateCode attribute metadata shows the isValidforCreate as No - we cannot set this attribute in Create transaction. Also when we set StatusCode only - we will face the error: 
2 is not a valid status code for state code AccountState.Active on account

Because, statecode=0 is set as default by system, when you pass statuscode=2 in create payload - the platform validation kicks in and say this is invalid pair.

Continue to website...

More from Arun Vinoth @ Dynamics

Related Posts