Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Missing LocalPluginContext , LocalPluginContext not fou

$
0
0

Hi i want to use LocalPluginContext, to get preimage entity, but i don't know why its missing, do i need to add any reference for this or it's already depecreated. so i need to get updated value from field and preupdated value from field and when im looking on the internet i found this usefull answer but i can't get LocalPluginContext 

protected void ExecuteYourPlugin(LocalPluginContext localContext)
{
    IPluginExecutionContext pluginContext = localContext.PluginExecutionContext;
    // Get Target Entity
    var updateEntity = (Entity)pluginContext.InputParameters["Target"];

    // Get PreImage Entity
    var preEntity = (Entity)localContext.PluginExecutionContext.PreEntityImages["PreImage"];

    // Is in Update
    if(localContext.PluginExecutionContext.MessageName.ToLower() == "update")
    {
        var fieldName = string.Empty;

            // If Contains, Extract value from Target Entity
            if(updateEntity.Contains("new_fieldname"))
            {
                // Cast the fields according their type
                fieldName = updateEntity["new_fieldname"].toString();
            }
            // Else extract the value from preImage
            else if(preEntity .Contains("new_fieldname"))
            {
                // Cast the fields according their type
                fieldName = preEntity["new_fieldname"].toString();
            }
    }

can someone help here thanks.


Viewing all articles
Browse latest Browse all 55831

Latest Images

Trending Articles



Latest Images

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