字典查找CRM C#插件中不存在给定的键 [英] the given key was not present in the dictionary lookup CRM C# Plugin

查看:98
本文介绍了字典查找CRM C#插件中不存在给定的键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用C#从CRM插件中的Lookup检索值的代码.很简单,从查找中读取guid,然后在异常中显示.

I have code to retrieve value from Lookup in CRM plugin using C#. It's simple, read guid from lookup then show it in exception.

//Get ParentCaseID
Guid HeaderId = ((EntityReference)entity["new_LookupTransactionHeader"]).Id;

throw new InvalidPluginExecutionException(HeaderId.ToString());

在这段代码中,我只想从查找中获取guid,但是当我运行插件时,却出现了这样的错误.

In this code I just want to get guid from lookup, but when I run the plugin I got error like this.

字典中不存在给定的键

the given key was not present in the dictionary

推荐答案

代码应该是不言自明的:

The code should be self-explenatory:

if(entity.Contains("new_LookupTransactionHeader")){
  Guid HeaderId = ((EntityReference)entity["new_LookupTransactionHeader"]).Id;
  throw new InvalidPluginExecutionException(HeaderId.ToString());
}
else
{
  throw new InvalidPluginExecutionException("There is no value in field new_LookupTransactionHeader.");
}

这篇关于字典查找CRM C#插件中不存在给定的键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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