Automatically activating Record Creation and Update rule - Dynamics CRM

56 Views Asked by At

I am importing a solution from Dev to target environment. In the solution there is a "Record Creation and Update" rule which after importing is set to "draft" status. Is there a way to be automatically / programmatically set to "active" status directly after importing the solution?

REcord Creation and Update Rule (https://i.stack.imgur.com/Ijnmv.png)](https://i.stack.imgur.com/Ijnmv.png)

I was expecting the rule to be "active" like in dev environment after importing the solution.

1

There are 1 best solutions below

0
Henk van Boeijen On

In C# activating a convert rule basically looks like this:

private void ActivateRule(Guid ruleId, IOrganizationService organizationService)
{
    organizationService.Update(new Entity("convertrule", ruleId)
    {
        ["statecode"] = new OptionSetValue(0),
        ["statuscode"] = new OptionSetValue(1)
    });
}

This is a basic update operation and therefore rules can also be activated using

  • A classic workflow
  • A Power Automate flow
  • The web API
  • etc.