如何使用C#更改CRM 2013中的状态/状态 [英] How to change State/Status in CRM 2013 using c#

查看:80
本文介绍了如何使用C#更改CRM 2013中的状态/状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C#更改CRM 2013中实体的状态和/或状态?

How do I change State and/or Status of an entity in CRM 2013 using C#?

CRM 2011的SetStateRequest和早期的SetStateDynamicEntityRequest均未被识别。
似乎也无济于事...我是否缺少名称空间或其他内容?

Neither CRM 2011's SetStateRequest nor the earlier SetStateDynamicEntityRequest are being recognized. Searching online didn't seem to help either... Am I missing a namespace or something?

预先感谢

命名空间:

using System;  
using System.Collections;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Net;  
using Microsoft.Xrm.Sdk;  
using Microsoft.Xrm.Sdk.Client;  
using Microsoft.Xrm.Sdk.Query;  
using Microsoft.Xrm.Sdk.Discovery;  
using Microsoft.Xrm.Sdk.Messages;  
using System.ServiceModel;  
using System.ServiceModel.Description;  
using System.Web.Services.Protocols;  

函数:

private void changeUserStatus(Guid userId, IOrganizationService service, int state)  
{  
    SetStateRequest setStateRequest = new SetStateRequest  
    {  
        EntityMoniker = new EntityReference("systemuser", userId),  
        State = new OptionSetValue(state),  
        Status = new OptionSetValue(-1),  
    };  
    service.Execute(setStateRequest);  
}  

重要提示:视觉无法识别我的SetStateRequest Studio 2012,因此与上面的示例不同,它没有突出显示,而是在悬停时显示红色的带未找到类型或名称空间消息的底线

IMPORTANT: My SetStateRequest is NOT recognized by visual studio 2012, so unlike the above example it's not highlighted and actually red underlined with the "the type or namespace not found" message displayed when hovering

编辑:我看到了问题投票失败,很抱歉如果我错过了什么,但是除了昨天我花了4个小时在网上寻找此信息(包括stackoverflow)之外,我真的没有更多信息可提供。我可能使用了错误的搜索条件或在错误的位置搜索,但是如果是这样的话,有人至少可以向我指出正确的方向吗?我是这一切的初学者(包括stackoverflow和crm2013),我对此有些固执。再次感谢

I see the question got downvoted and I'm sorry if I'm missing something but I really have no more information to provide apart from the fact that I've spent 4 hours yesterday looking for this online (including stackoverflow) without any avail. I may be using the wrong search criteria or looking in the wrong places, but if that's the case could anyone at least point me in the right direction? I'm a beginner on all of this (both stackoverflow and crm2013) and I'm kind of stuck on this. Thanks again

推荐答案

您未引用 microsoft.crm.sdk.proxy.dll 及其命名空间 Microsoft.Crm.Sdk.Messages

You are not referencing microsoft.crm.sdk.proxy.dll and its namespace Microsoft.Crm.Sdk.Messages

因此代码将

using Microsoft.Crm.Sdk.Messages;

另一件事,请确保 State 状态对实体有效(在您的情况下为 systemuser

Another thing, be sure that the int values for State and Status are valid for the entity (in your case systemuser)

这篇关于如何使用C#更改CRM 2013中的状态/状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆