Assign new owner to appointment. “There should be only one owner party for an activity”

前端 未结 3 1868
别那么骄傲
别那么骄傲 2021-01-13 12:09

I need to change the owner of an appointment record when creating a new appointment. I\'m using a plugin for the create message and i\'ve found this code to assign a new own

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-13 13:00

    Guid id= new Guid("{33011A68-D311-E211-A429-005056820002}");    
     switch (context.MessageName)
                    {
                        case "Update":
                            {
                                try
                                {
                                    if (ent.Contains("fieldname") == true)
                                    {
    
                                        AssignRequest assign = new AssignRequest
                                        {
                                            Assignee = new EntityReference("systemuser", id),
                                            Target = new EntityReference(ent.LogicalName, ent.Id)
                                        };
                                        _service.Execute(assign);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    throw new InvalidPluginExecutionException("Error" + Environment.NewLine + "Details: " + ex.Message);
                                }
                            }
                            break;
                    }
    

提交回复
热议问题