Creating a rule in FC 12 Document Definition that Divides Amount with Quantity in Invoice Table

 How can I create a rule that divides Amount value with Quantity to get unit price in Invoice table, Please Share the script for this case.

Was this article helpful?

0 out of 0 found this helpful



  • Avatar
    Tatiana Dyu

    Hello, you can create a script rule to calculate the unit price. Details about setting up the rule can be found in

    A sample script in C# is below, but please note you may need to adjust it based on your settings and requirements.

    double quantity = double.Parse( Context.Field( "Quantity" ).Text );
    double totalPriceNetto = double.Parse( Context.Field( "TotalPriceNetto" ).Text );
    double unitPrice = totalPriceNetto/quantity;
    Context.Field( "UnitPrice" ).Text = unitPrice.ToString();

    Thank you.



  • Avatar
    Mahmoud Mostafa

    Hello , i tried a similar script that multiple two columns as shown in the below script: 

    double NetQuantity = double.Parse( Context.Field( "Quantity" ).Text );
    double NetWeight = double.Parse( Context.Field( "Unit_weight" ).Text );
    NetQuantity = NetQuantity*NetWeight;
    Context.Field( "Quantity" ).Text = NetQuantity.ToString();


    but there is issue as shown in attachment,please advise how to solve it

  • Avatar
    Tatiana Dyu

    Hello, I am afraid we will need your project and some sample for further investigation. I have created a support ticket, my colleagues will reach out to you shortly. Thank you.


Please sign in to leave a comment.