c# - CRM v9 - 通过 C# 代码将数据保存在 CRM 实体中
问题描述
我创建了一个新的 CRM 实体,其中包含 2 个字段Name和Value。在我的 C# 代码中,我从 Microsoft Unified Service Desk 获取相同的两个值及其名称。现在我的 C# 代码中有这些记录,现在我想将它们保存在 CRM 实体中。我现在使用下面的代码来获取值,
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中获取Name,在QuestionAnswer中获取Value。我想将这些记录存储在具有名称和值字段的 CRM 实体中。
解决方案
您在 CRM 中创建记录的代码如下所示
实体 customEntity = 新实体
Entity abc = new Entity()
{
LogicalName = "new_EntityName",
["fieldName"] = ContextParameterName,
["fieldValue"] = QuestionAnswer
};
Guid newEntityRecordGuid = CrmConn.Create(abc);
newEntityRecordGuid 将具有新创建的 Record Guid
推荐阅读
- python - Google App Engine Flask 413 请求实体太大错误
- ready-api - 当我尝试访问 URI 并在 Ready API 中查找请求数时,我得到 406
- javascript - 如何实现最多N级的递归在Node js中的每个级别都有对象数组?
- javascript - 访问动态加载的 JavaScript 函数
- php - substr_count php 函数是如何工作的?
- javascript - 如何在 sequelize(SQLite) 中编写不区分大小写的顺序查询?
- xamarin.forms - Xamarin.forms Rg.Plugins.Popup 背景页面模糊
- dynamics-crm - 如何知道哪个字段连接到选项集值组
- python - 如何使用 Textblob 将列(excel 文件)的语言翻译成英文?
- python - 从标准输出记录第 3 方消息并通过 python 中的发布请求发送