Loading...

Can I create an INACTIVE record?

Can I create an INACTIVE record?
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.

Published on:

Learn more
Arun Vinoth @ Dynamics
Arun Vinoth @ Dynamics

Share post:

Related posts

Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy