Follow

APP: How Do I Set-Up Local Value Calculation? Usage Of OnAfterGetRecord Trigger

What This Article Is About

This article describes how to do a calculation on the mobile app using Anveo Script. Example: Calculate total amount of order based on sales lines.

 

Solution

  1. Add a new field Anveo Total Amount in Sales Header table.

  2. Add this field to your Synchronization package mark this field with Do not send
    updates to NAV.


  3. Create a new Action Code that is responsible for your calculation and for opening the Anveo Page.

    Example Code: Coming from Sales Order List, srcRec is also Sales Header.

    PAGE('LOCKPAGE');
    local SalesHeader = Record('Sales Header');
    SalesHeader:GET(srcRec:GETVALUE('Document Type'),
      srcRec:GETVALUE('No.'));
    --[[ Put your calculation here...]]
    SalesHeader:MODIFY();
    PAGE('UNLOCKPAGE');
    PAGE_OPEN('SALESORDER', SalesHeader, SalesHeader);

  4. Add your new field to your Sales Header Anveo Page.

    Please note: It is not allowed to do precalulations in OnAfterGetRecord or OnOpen Trigger of the Anveo Page to manipulate the current record.
    These triggers can only be used to do PAGE('SFA',...) commands.

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

  • Avatar
    Eyrun Ingadottir

    Hi,
    I created a new library where I placed functions to do similar calculations (total order amount, total + VAT, etc.), which I call when I first open the page for an existing order and it works fine.
    However, I'm not sure where I should place code to update the calculation when the user adds new lines to order in the following process:
    Open Sales Header Page -> Add lines (in other pages) -> return to Sales Header.
    My best guess is in Mobile Table Trigger for Table 37 Field Quantity - do you agree or do you have a better suggestion?

    Kind regards,
    Eyrún