Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 143529

Some form fields are not in the attributes - plugins

$
0
0

Hi, i'm trying to get some fields values in a plugin , the problem is that those fields names don't appear in the attributes. in the form i have a field which has "old email" display name and "new_oldemail" name , but the name doesn't appear in the attributes , and when i try to fetch this field using it's name, and exception occurs.

 public void Execute(IServiceProvider serviceProvider)
        {
            ITracingService tracingService = serviceProvider.GetService(typeof(ITracingService)) as ITracingService;
            IPluginExecutionContext context = serviceProvider.GetService(typeof(IPluginExecutionContext)) as IPluginExecutionContext;
            IOrganizationServiceFactory serviceFactory = serviceProvider.GetService(typeof(IOrganizationServiceFactory)) as IOrganizationServiceFactory;
            tracingService.Trace("context message:{0}",context.MessageName);
            if (context.MessageName.ToLower() == "update")
            {
                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                {
                    Entity currentCaseEntity = context.InputParameters["Target"] as Entity;
                    tracingService.Trace("entity logical name is :{0}", currentCaseEntity.LogicalName);
                    if (currentCaseEntity.LogicalName == "incident")
                    {
                        try
                        {
//this field exists bool emailAprrove = (bool) currentCaseEntity["new_emailapprove"]; tracingService.Trace("email approve value :{0}",emailAprrove); if (emailAprrove) { var attributes = currentCaseEntity.Attributes; foreach (var VARIABLE in attributes) { tracingService.Trace("attribute : {0}",VARIABLE); }
// and exception occurs here, and "new_oldemail" is not in the attributes
tracingService.Trace("attribute : {0}", currentCaseEntity["new_oldemail"]); } } catch (Exception e) { throw new InvalidPluginExecutionException("an exception occured: " , e); } } } } }





Viewing all articles
Browse latest Browse all 143529

Trending Articles



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