Passing Parameters to Functions
Passing parameters to functions is straightforward in Business Central, which should be a similar experience in COSMO Mobile Solution. Currently, we support three methods for passing parameters to functions:
- Using a Parameter Page function action
- Setting the value directly on the current page
- Entering the value in a popup dialog before executing the function
Problem
At times, executing a function requires additional information. While this is easily managed in Business Central, it posed challenges in COSMO Mobile Solution.
Solution
The three methods for passing parameters to functions in COSMO Mobile Solution and the steps for their implementation are described in the following sections.
Parameter Page Function Action
This method is preferred for complex solutions. It involves creating a new Card type page to serve as the parameter page. This page can include captions, conditional views, an OnOpen
trigger, and access to records from Business Central. The names and data types of the fields on this page should match those of the parameters being passed. If the OnOpen
function encounters an error, the function's execution will be halted.
Implementation Steps
- Create a new page in Business Central.
- Design a COSMO Mobile Solution page of Card type.
- Add a drilldown on the page containing the function, ensuring the use of filters for page accessibility.
- In the function, add a new function action with the Run Time field set to Before Action, the Function Action field set to Parameter Page, and then choose the previously created drilldown in the Action Parameter field.
Refer to the CCSMSSerialNoCreationWS and CCSMSItemTrackingListWS global customization pages for examples.
Example Code Snippets
Function receiving parameters:
internal procedure CreateBatchSerialNos(... SourceRec_TableNo: Integer; Item_No: Code[20];...)
Parameter page source code for passing parameters:
...
field(SourceRec_TableNo; Rec."Integer 1")
{
ApplicationArea = All;
}
...
field(Item_No; Rec."Code 1")
{
Caption = 'Item No.';
ApplicationArea = All;
Editable = false;
}
Setting the Value on the Current Page
This simpler solution allows for parameter fields to be added directly to the page containing the function. The field names and data types must match the parameters' names and data types. If both the parameter page and the current page contain the parameter, the one from the parameter page takes precedence.
Implementation Steps
- Add a new field to the existing page to serve as a parameter.
- Refresh the page schema to make the new field available in COSMO Mobile Solution.
Example Code Snippets
Function receiving parameters:
internal procedure AddItemTrackingLine(... Scan_Serial_No: Code[50]; Scan_Lot_No: Code[50];...);
Page source for passing parameters:
field("Scan Lot No."; Rec."CCS MS Lot No.")
{
ApplicationArea = CCSMS;
ToolTip = ' ', Locked = true;
Editable = true;
Caption = 'Scan Lot No.';
}
field("Scan Serial No."; Rec."CCS MS Serial No.")
{
ApplicationArea = CCSMS;
ToolTip = ' ', Locked = true;
Editable = true;
Caption = 'Scan Serial No.';
}
Filling the Value in a Popup Dialog Before the Function
This older method is still supported but not recommended for regular use. It automatically triggers a new dialog for each parameter without captions. This method is a fallback if no other parameter passing method is implemented.
Feedback
Submit feedback for this page .