Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Reopen appointment to change the field and return to the original state.

$
0
0

I am creating a plugin where I need to change a field of multiple appointments in CRM, but when I try to open the appointment I get the message "Cannot update Closed or Cancelled Activity". can anybody help me?

  setState(0, 1, newEntity.ToEntityReference(), service, item.LogicalName, erro);
  newEntity[attributte] = new EntityReference(Account.LogicalName, Account.Id);
  service.Update(newEntity);
  setState(((OptionSetValue)savedState["statecode"]).Value, ((OptionSetValue)savedState["statuscode"]).Value, newEntity.ToEntityReference(), service, item.LogicalName, erro);


 public void setState(int stateCode, int statusCode, EntityReference entity, IOrganizationService service, string entityName, string erro)
  {
                   SetStateRequest state = new SetStateRequest();

                    // Set the Request Object's Properties
                    state.State = new OptionSetValue((int)stateCode);
                    state.Status = new OptionSetValue((int)statusCode);

                    // Point the Request to the case whose state is being changed
                    state.EntityMoniker = entity;

                    // Execute the Request
                    SetStateResponse stateSet = (SetStateResponse)service.Execute(state);
                }



Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>