Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Some form fields are not in the attributes - plugins

Posted on by 145

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); } } } } }




*This post is locked for comments

  • Khaled Rimawi Profile Picture
    Khaled Rimawi 145 on at
    RE: Some form fields are not in the attributes - plugins

    Thank you, this is so correct :)

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Some form fields are not in the attributes - plugins

    Hi Khaled,

    If the field Old Email (schema name: new_oldemail) hasn't changed, it will not appear in the attribute collection. You will need to use images (Pre-image and Post-image) to get the values of this attribute. You can read more about Images here

    -Sara

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans