Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

How To Create a Plugin Oncreate For Search , Set and Control Attributes to some Entities

Posted on by 10

Hi, I have the Dynamics 365 trial, I create a new Solution with new Entities end new Attributes to the Out Of the box Entities

I want to create a Plugin for a custom entity.

The entity is called WorkActivity, it has a lookup with another custom entity called Project and Project have a lookup with Account

I want the plugin control (OnCreate) if there's an Order associated with the same Account set in the Project's Account lookup, with a custom attribute (on Order) set to true.
If the plugin found it, I want to change the record and add a lookup (On WorkActivity) with the first-order found.
When the record change, the plugin control if the number of WorkActivity associated with the Order is greater than a custom (number) Attribute (added to Order)

I do not know where to begin.

I'm Italian, sorry for my bad English.

Thanks

  • Samuele Profile Picture
    Samuele 10 on at
    RE: How To Create a Plugin Oncreate For Search , Set and Control Attributes to some Entities

    Thanks, i resolve.

  • Verified answer
    RE: How To Create a Plugin Oncreate For Search , Set and Control Attributes to some Entities

    Hello Samuele,

    I think it will be easier to perform the whole operation with the visual aid of a schema.

    If I understood your schema correctly:

    WorkActivity(lookup) <---- Project(lookup) <---- Account ----> Order(lookup) ----> WorkActivity(lookup)

    At this point, you might need two plugins.

    Create plugin (registered in WorkActivity) in PreOperation:

    - Extract the lookup value to Project from the "Target" and retrieve the Account lookup value [Column] from the Project record [Entity to query]

    - Having the Account entity reference, query orders that have this account (QueryExpression) that have the custom attribute set to true

    - If the entitycollection > 0 -> populate the lookup field in WorkActivity with that order entity reference

    ==

    For the second part, regarding the record change control, you should need a plugin on update, but I couldn't understand what you are trying to achieve.

    Hope this helped clearing up the whole scenario.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans