Hi,
We can Activate\Deactivate record using “SetStateRequest“. Below is the code snippet.
private void SetEntityStatus(IOrganizationService service, Guid recordGUID, string entityName) {
SetStateRequest setState = newSetStateRequest();
setState.EntityMoniker = newEntityReference();
//Pass GUID of the record to be activated or Deactivated
setState.EntityMoniker.Id = recordGUID;
setState.EntityMoniker.Name = entityName;
setState.EntityMoniker.LogicalName = entityName;
//Setting ‘State’ i.e., (0 – Active ; 1 – InActive)
setState.State = new OptionSetValue();
setState.State.Value = 0/1;
//Setting ‘Status’ i.e., (1 – Active ; 2 – InActive)
setState.Status = new OptionSetValue();
setState.Status.Value = 1/2;
SetStateResponse setStateResponse = (SetStateResponse)service.Execute(setState);
}
Hope it helps 🙂

![[Step by Step] Beginner : Create a PCF control and add it to a custom page](https://rajeevpentyala.com/wp-content/uploads/2024/12/image-49.png)

Leave a reply to સર્જનWebDev (@sarjanwebdev) Cancel reply