首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CRM v9 -通过C#代码在CRM实体中保存数据

CRM v9 -通过C#代码在CRM实体中保存数据
EN

Stack Overflow用户
提问于 2019-04-04 07:29:32
回答 3查看 538关注 0票数 2

我已经创建了一个新的CRM实体,它包含两个字段NameValue。在我的C#代码中,我从获取相同的两个值及其名称。现在我在我的C#代码中有了这些记录,现在我想将这些记录保存在CRM实体中。我现在使用下面的代码来获取值,

代码语言:javascript
复制
 string QuestionAnswer = string.Empty;

        if (dialog.QuestionControlValidate)
        {
            if (ContextParameterName != string.Empty)
            {
                var ctx = Context.GetContext();

                if (dialog.QuestionControlType == "TextBox")
                    QuestionAnswer = dialog.QuestionControlTextQuestionAnswer.ToString();
                else if (dialog.QuestionControlType == "RadioButton")
                    QuestionAnswer = dialog.QuestionControlRadioButtonSelectionAnswer.ToString();

                var updatedContext = new Context(ctx)
                {
                    [ContextParameterName] = QuestionAnswer
                };

// Code to be added here
            }

我在ContextParameterName中获取名称,在QuestionAnswer.中获取我想将这些记录存储在具有名称和值字段的CRM实体中。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2019-04-04 11:35:09

我是从C#代码中从微软美元获得数据,然后想把它保存在客户关系管理实体。因为在美元中,连接是用CRM环境自动创建的,所以我实现了它,而没有显式地定义连接。

代码语言:javascript
复制
                dictionary.Add("name", new CrmDataTypeWrapper(ContextParameterName, CrmFieldType.Raw));
                dictionary.Add("value", new CrmDataTypeWrapper(QuestionAnswer, CrmFieldType.Raw));
                dictionary.Add("id", new CrmDataTypeWrapper(updatedContext["Id"], CrmFieldType.Raw));

                Guid EvntId = _client.CrmInterface.CreateNewRecord("historicaldata",dictionary,"",false,new System.Guid());

CreateNewRecord方法针对目标实体类型创建新的活动。

票数 0
EN

Stack Overflow用户

发布于 2019-04-04 08:42:20

在CRM中创建记录的代码如下所示

实体customEntity =新实体

代码语言:javascript
复制
 Entity abc = new Entity()
                {
                    LogicalName = "new_EntityName",
                    ["fieldName"] = ContextParameterName,
                    ["fieldValue"] = QuestionAnswer

                };
                Guid newEntityRecordGuid = CrmConn.Create(abc);

newEntityRecordGuid将有新创建的记录Guid

票数 0
EN

Stack Overflow用户

发布于 2019-04-04 20:31:30

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55510162

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档