cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anthony_Dob
Responsive Resident
Responsive Resident

Calculations On relating In Model Driven App

Hi guys,

 

Here is my usecase. I am making a model driven app to manage training budgets of our employees. There is a few calculations that would have to happen inside the model driven app and i would love some advice in how to achieve this. The only way i can think off for this to work, is power automate flows. Here are the calculations that would need to happen:

 

  • On adding a training
    • Cost of the training would need to be subtracted from all employees budget attending the training
    • Duration in days of the training would need to be subtracted from all employees training days budget attending
  • On adding a extra cost to a specific training (hotel, flight, etc) -> Extra Cost should be substracted for all employees related to this extra cost
  • When updating costs
    • Employee budget should be recalculated with the updated cost
  • When deleting costs
    • Cost should be returned to the employees witch it was related to.

This gives you guys an idea of what calculations should be made. What would be the best way to go?

 

Best Regards,
Anthony

2 ACCEPTED SOLUTIONS

Accepted Solutions
bipinshan
Super User
Super User

Hi,

 

If you are looking for no code low code solution the Power automate is your best friend. But Power automate runs in background so it will take some time to take affetc the calculations on your model driven forms/views.

 

Other approach is to use Plugin which can rn synchronous and ability to add complex calculation l ogic using plugin. But it requires pro developer to write the plugin code for you.

 

Please mark my answer verified if this is helpful!

Regards,

Bipin Kumar

Follow my Blog: https://xrmdynamicscrm.wordpress.com/

View solution in original post

Anthony_Dob
Responsive Resident
Responsive Resident

I have some additional information to this matter which i think will be helpfull for a lot of people with this scenario.

For the plugin code use the following link:

https://rajeevpentyala.com/2013/04/17/associatedisassociate-plugin-messages-in-crm/

 

To Implement this code you have to write this code in a C# class library. Then you need to register the [Projectname].dll file (which can be found at [Your project folder]/bin/debug/[Projectnale].dll) in the Plugin Registration Tool as a assemblie.

 

Add a step to the assemblie that handles the Associatie/Diassociate event and you are good to go.

 

Best Regards,

Anthony

View solution in original post

6 REPLIES 6
bipinshan
Super User
Super User

Hi,

 

If you are looking for no code low code solution the Power automate is your best friend. But Power automate runs in background so it will take some time to take affetc the calculations on your model driven forms/views.

 

Other approach is to use Plugin which can rn synchronous and ability to add complex calculation l ogic using plugin. But it requires pro developer to write the plugin code for you.

 

Please mark my answer verified if this is helpful!

Regards,

Bipin Kumar

Follow my Blog: https://xrmdynamicscrm.wordpress.com/

@bipinshan ,

 

So with a bit of research i came on the same thing you just told me. We are using the webhook registration tool to call to custom api's we are building on certain triggers. One trigger is the "Associate" one. Have you ever worked with this trigger? I'm looking for a way to filter on the entities i want the plugin to trigger on (default it triggers on all entities in your environment). Should you write that logic in the api you are connection the plugin to or is it some setting in the plugin registration step. I can't seem to find a setting for it because its a N:N.

Best Regards,

Anthony

rampprakash
Super User
Super User

Hello @Anthony_Dob,

 

If you want to trigger this process in async Mode we are good to go with Microsoft Flow, if you want to trigger in Sync Mode then you need to go with Plugins.

 

For Plugins:

 

Write plugins on Associate Operation while Adding Training (Message as ASSOCIATE and Select the Entity)

 

https://community.dynamics.com/crm/b/mylifemicrosoftdynamiccrm/posts/ms-dynamics-crm-associate-disas...

 

Above link helps you for Associate Operation.

 

Please mark as Answer if it is helpful and provide Kudos


Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
Blog : https://microsoftcrmtechie.blogspot.com

 

 

@rampprakash,


Where do i implement the code to trigger on a specific relationshipName? Should this be implemented somewhere in the registration step?
Inked2021-12-15 11_36_52-Plugin Registration Tool_LI.jpg

 

I can't believe you should implement this in the API it is directing to? This would cause the API to be called a lot of times when relate/unrelates in the environment happen.

 

Best Regards,

Anthony

rampprakash
Super User
Super User

Hello @Anthony_Dob,

 

In the Plugin Code we need to use IF condition to compare the Relationship.

 

https://rajeevpentyala.com/2013/04/17/associatedisassociate-plugin-messages-in-crm/

 

This link contains all the Code in one of the Place he mentioned "YOUR RELATION NAME" there we need to mention our relationship name to proceed.

 

Make sure you will provide NONE in both primary and Secondary entity

 

Please let me know if you need more guidance or you can give a private chat.

 

Please mark as Answer if it is helpful and provide Kudos


Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
Blog : https://microsoftcrmtechie.blogspot.com

 

Anthony_Dob
Responsive Resident
Responsive Resident

I have some additional information to this matter which i think will be helpfull for a lot of people with this scenario.

For the plugin code use the following link:

https://rajeevpentyala.com/2013/04/17/associatedisassociate-plugin-messages-in-crm/

 

To Implement this code you have to write this code in a C# class library. Then you need to register the [Projectname].dll file (which can be found at [Your project folder]/bin/debug/[Projectnale].dll) in the Plugin Registration Tool as a assemblie.

 

Add a step to the assemblie that handles the Associatie/Diassociate event and you are good to go.

 

Best Regards,

Anthony

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Users online (3,641)