CRM2011共享记录、更改状态、分派记录

   #region 停用记录状态
        /// <summary>
        /// 信用记录状态
        /// </summary>
        /// <param name="service"></param>
        /// <param name="entity">实体</param>
        /// <param name="state">状态</param>
        /// <param name="status">状态描述</param>
        public void SetEntityState(IOrganizationService service, EntityReference entityMoniker, int state, int status)
        {

            SetStateRequest setRequest = new SetStateRequest()
            {
                EntityMoniker = entityMoniker,
                State = new OptionSetValue(state),
                Status = new OptionSetValue(status),
            };
            SetStateResponse setResponse = (SetStateResponse)service.Execute(setRequest);


        }
        #endregion
        #region 共享记录
        /// <summary>
        /// 共享记录
        /// </summary>
        /// <param name="service"></param>
        /// <param name="teamOrSystem">要共享给用户或者团队</param>
        /// <param name="target">要共享的记录</param>
        public void Grant(IOrganizationService service, EntityReference teamOrSystem, EntityReference target)
        {
            GrantAccessRequest grantAccessRequest = new GrantAccessRequest
            {
                PrincipalAccess = new PrincipalAccess
                {
                    Principal = teamOrSystem,
                    AccessMask = AccessRights.ReadAccess | AccessRights.WriteAccess

                },
                Target = target,
            };

            service.Execute(grantAccessRequest);

        }
        #endregion
        #region 分派记录
        /// <summary>
        /// 分派记录
        /// </summary>
        /// <param name="service"></param>
        /// <param name="teamOrSystem">分派给用户或者团队</param>
        /// <param name="target">要分派的记录</param>
        public void Assing(IOrganizationService service, EntityReference teamOrSystem, EntityReference target)
        {
            AssignRequest assign = new AssignRequest()
            {
                Assignee = teamOrSystem,
                Target = target,
            };
            service.Execute(assign);
        }
        #endregion

 

posted on 2012-07-24 18:04  HelloHongfu  阅读(369)  评论(0编辑  收藏  举报

导航