CRM SDK 2013活动在创建后不存在

时间:2016-10-29 03:20:59

标签: dynamics-crm dynamics-crm-2013

我有一个自定义评论活动,我正在更新代码,这曾经工作但最近开始失败。它会创建活动,但当我尝试检索它或对其执行SetStateResponse时,我得到“tk_comment与Id = 9a1686d1-7d9d-e611-80e3-00155d001104不存在” - 这是没有意义的,因为我刚刚创建它!活动记录显示在帐户中,但我无法在那里点击或执行任何操作(记录不可用 - 找不到请求的记录,或者您没有足够的权限来查看它。)。

这是我正在使用的代码。我爱你告诉我,我犯了一些简单的错误:)

        using (_serviceProxy = ServerConnection.GetOrganizationProxy(serverConfig))
        {
            _serviceProxy.EnableProxyTypes();
            try
            {
                tk_comment comment = new tk_comment();
                int maxLength = 190; //subject has a max length of 200 characters
                if (subject.Length > maxLength)
                {
                    comment.Subject = subject.Substring(0, maxLength);
                    comment.Description = subject.Substring(maxLength, subject.Length - maxLength);
                }
                else
                {
                    comment.Subject = subject;
                }

                comment.RegardingObjectId = entity.ToEntityReference();
                comment.ActualStart = CommentDate;
                comment.ActualEnd = CommentDate;
                comment.ScheduledStart = CommentDate;
                comment.ScheduledEnd = CommentDate;
                Guid commentID = _serviceProxy.Create(comment);
                try
                {
                    tk_comment aComment = (tk_comment)_serviceProxy.Retrieve(tk_comment.EntityLogicalName, commentID, new ColumnSet(allColumns: true));
                }
                catch (Exception ex)
                {

                    SingletonLogger.Instance.Error("Always an error here " + ex.Message);
                }
                Account test = (Account) _serviceProxy.Retrieve(Account.EntityLogicalName, entity.Id, new ColumnSet(allColumns: true));

                //   tk_comment newComment =  (tk_comment)_serviceProxy.Retrieve(tk_comment.EntityLogicalName, commentID, new ColumnSet(allColumns: true));
                SetStateRequest request = new SetStateRequest();
                request.EntityMoniker = new EntityReference(tk_comment.EntityLogicalName, commentID);
                request.State = new OptionSetValue((int) tk_commentState.Completed); //completed
                request.Status = new OptionSetValue(2); //completed
                SetStateResponse response = (SetStateResponse)_serviceProxy.Execute(request); //always an error here too

            }

感谢任何建议

干杯,米克

1 个答案:

答案 0 :(得分:0)

您似乎没有此自定义活动实体的正确读取权限。 或者您需要验证此自定义实体的所有权限。