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

Community site session details

Session Id :
Customer Service forum

Custom Workflow to add two decimal fields.

(0) ShareShare
ReportReport
Posted on by 30

I want to write a custom workflow to add two decimal fields in Account Entity and store the result in a different field. Can anyone suggest the simplest way to achieve this via custom workflows? I don't want to use calculated fields or JS.

Thank You

I have the same question (0)
  • Verified answer
    Satish1024 Profile Picture
    107 on at
    RE: Custom Workflow to add two decimal fields.

    There you go. I have written code for you. Make sure you create a built-in workflow and call this one from it. 

    For tutorials on Custom Workflows, you can visit my course https://www.udemy.com/dynamics-365-crm-developer-technical-training/


    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using Microsoft.Xrm.Sdk.Workflow; using System.Activities; namespace MyCustomWorkflows { public class GetTaxWorkflow : CodeActivity { [Input("Value1")] public InArgument<Decimal> Value1 { get; set; } [Input("Value2")] public InArgument<Decimal> Value2 { get; set; } [Output("Sum")] public OutArgument<Decimal> Sum { get; set; } protected override void Execute(CodeActivityContext executionContext) { //Create the tracing service ITracingService tracingService = executionContext.GetExtension<ITracingService>(); //Create the context IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); decimal value1 = Value1.Get(executionContext); decimal value2 = Value2.Get(executionContext); Sum.Set(executionContext, value1 + value2 ); } }

    }
  • Verified answer
    Aman Shaw Profile Picture
    30 on at
    RE: Custom Workflow to add two decimal fields.

    Thank You very much for the response. This helped me a lot to understand the working.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans