web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Convert Dynamic Entity to Entity (kbarticle)

(0) ShareShare
ReportReport
Posted on by 615

 Hi All,

 I have a plugin that is set up on the kbarticle entity and is triggered by the update event.  I am able to get the Dynamic Entity from the  context using the following

 

Dim de As DynamicEntity = CType(context.InputParameters.Properties("Target"), DynamicEntity)

 

Now what I need to do is  convert or cast this Dynamic Entity to the business entity type kbarticle.  Can I do something to convert it or do I have to use the guid and then use retreive via the crmservice?

 

Thanks,

 

Russ

*This post is locked for comments

I have the same question (0)
  • Rhett Clinton Profile Picture
    Moderator on at

    Hi Russ, you can do it this way http://msdn.microsoft.com/en-us/library/cc151177.aspx

     I think the general concept is to deal with dynamic entity when using the dll's as opposed to the web service and as the plugins utilise the sdk dll's I would recommend staying with dynamic entity if you can. Is there a specific reason beside having a nicely typed class that you are trying to convert to a core entity? I also think the sdk dll crm core types are depreciated in CRM 4 but I'd have to double check that.

  • Russell Bahr Profile Picture
    615 on at

     Hi Rhett,

     For some reason when I tried to get the properties of the dynamic entity there were only 2 of the many that the entity has.  I was bale to get the GUID and then use the code below to retrieve the kbarticle and get the rest.   Thanks for the help.

     

    Dim de As DynamicEntity = CType(context.InputParameters.Properties("Target"), DynamicEntity)

                    'get the kbarticles guid from the property bag
                    Dim kbGuid As Guid = Nothing
                    For Each p As KeyProperty In de.Properties
                        kbGuid = p.Value.Value
                        Exit For
                    Next

                    'lookup the article using the service and the kbarticles guid
                    Dim service As ICrmService = CType(context.CreateCrmService(False), ICrmService)
                    Dim kba As kbarticle = CType(service.Retrieve(EntityName.kbarticle.ToString(), kbGuid, New AllColumns()), kbarticle)
     

  • Rhett Clinton Profile Picture
    Moderator on at

    The input parameters will only pass through the values that changed on the form. You can register a Post Image for the plugin step and select the attributes you want from there.

     Instead of using context.InputParameters.Properties("Target"), you will use context.PostEntityImages.Properties("PostImage") when you register a post image against the plugin step. You can call the post plugin step what ever you want but I have named it PostImage here,

  • Russell Bahr Profile Picture
    615 on at

    I will give this a shot and let you know how it goes.  Thanks Rhett!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans