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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin vs WF to calculate fields?

(0) ShareShare
ReportReport
Posted on by

Hello expert ,

I need your advice/Best approch to achieve my requirements.

I have one customized entity "PriceofService", in this entity i have two fields :"PriceofServiceAdult" & "PriceofServicechild" .

for now i have a plugin that calculate the price of the service based on those fields & also based on: "groupeprice" & "residence".

I need to add two fields validity start date & validity end date to the entity "PriceofService" because i need to make some changes to the price of services depending on a validity date.

public static decimal[] LoadServicePrice(LocalPluginContext context,
rea_PropLine PropLine)
{
Money ServicePriceAdult = new Money(0);
Money ServiceChild = new Money(0);

decimal[] tabService = new decimal[2];

if (PropLine.rea_tarifService==null)
{
PropLine.rea_tarifService = false;
}
//
if (PropLine.rea_tarifService.Value)
{
QueryExpression servicePriceQe = new QueryExpression(zz_serviceprice.EntityLogicalName);
servicePriceQe.ColumnSet = new ColumnSet();
servicePriceQe.ColumnSet.AddColumn(zz_serviceprice.Columns.zz_servicePrice);
servicePriceQe.ColumnSet.AddColumn(zz_serviceprice.Columns.rea_prixchild);
servicePriceQe.Criteria = new FilterExpression();
servicePriceQe.Criteria.AddCondition(zz_serviceprice.Columns.rea_pricelistgroupid, ConditionOperator.Equal, PropLine.rea_pricelistgroupid.Id);
servicePriceQe.Criteria.AddCondition(zz_serviceprice.Columns.zz_residenceid, ConditionOperator.Equal, PropLine.zz_residence.Id);
servicePriceQe.Criteria.AddCondition(zz_serviceprice.Columns.statecode, ConditionOperator.Equal, (int)zz_servicepriceState.Active);
// servicePriceQe.Criteria.AddCondition(zz_serviceprice.Columns.rea_Date_debut_validite, ConditionOperator.Equal, PropLine.rea_pricelistgroupid.Id);

EntityCollection servicePrice = context.OrganizationService.RetrieveMultiple(servicePriceQe);
if (servicePrice.Entities.Count == 0)
{

ServiceChild = ((Money)servicePrice.Entities.First()[zz_serviceprice.Columns.rea_prixchild] == null) ? ServiceChild : (Money)servicePrice.Entities.First()[zz_serviceprice.Columns.rea_prixchild];
tabService[0] = ServicePriceAdult.Value;
tabService[1] = ServiceChild.Value;
}
else
{

}

return tabService;
}

Best Regards,

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Ben Thompson Profile Picture
    6,350 on at

    Given that you already have a plugin and that the requirement would still need a custom workflow activity as you cannot perform the requirement using the out of the box workflow I would continue to use a plugin and would probably just update the current one.

  • Community Member Profile Picture
    on at

    Thank you Ben for your reply, ill try to update mine.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans