Quantcast
Channel: CRM Development 論壇
Viewing all articles
Browse latest Browse all 10280

CRM 2011: Assign the value of an empty lookup field to an output parameter

$
0
0

Hi all,

Currently I'm developing a custom workflow activity that retrieve a value form a lookup field and assign it to an output parameter. I have used the below code:

Guid fieldId = new Guid();
if (Entity.Attributes.Contains("new_lookupfield") == true)
				{
					fieldId = ((EntityReference)Entity.Attributes["new_lookupfield"]).Id;
					OutParam.Set(context, new EntityReference("new_entity", fieldId));
}

My problem is with setting the value of the output parameter when the lookup field is empty. I have tried to use

OutParam.Set(context, new EntityReference("new_entity", fieldId));

Outside the if condition but it throws and invalid argument exception

Please advise..


Viewing all articles
Browse latest Browse all 10280

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>