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
- Add a new field Anveo Total Amount in Sales Header table.
- Add this field to your Synchronization package mark this field with Do not send
updates to NAV. - 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); - 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.
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