Skip to main content

Notifications

Announcements

No record found.

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

  • Community Member Profile Picture
    on at
    RE: Plugin vs WF to calculate fields?

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

  • Verified answer
    Ben Thompson Profile Picture
    6,350 on at
    RE: Plugin vs WF to calculate fields?

    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.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans