🧩 Using the Command Line in Document Customizer
The Command Line in Document Customizer allows you to print data that isn’t directly available in the current table. Unlike the “Using Table” method, the Command Line preserves the original text if no matching data is found in the linked table. For example, if no item translation exists for a specific item number, the system will print the item’s default description instead.
🛠️ When to Use the Command Line
- When you need to print data from a related table that isn’t directly linked.
- When multiple keys are required to link to another table (e.g., linking to both Payment Terms and Shipment Method in a header).
⚠️ Important: Avoid Special Characters in Field Values
Using special characters (such as &
, %
, #
, @
, etc.) in field values can cause issues when performing advanced lookups with LookupRecord
and GetFieldValue
. These characters may interfere with how expressions are parsed or matched, leading to lookup failures or unexpected behavior.
✅ Best Practice:
Avoid using special characters in any field values that will be referenced in:
ParentLinkFields
LookupTableViewExpression
LookupTableViewValues
💡 Advanced Value Lookup
The Command Line supports two key functions for advanced lookups:
📇 1. LookupRecord
This function retrieves a record from a related table using a parent record. It requires six parameters:
LookupRecord(
ParentRecIDText: Text[1024], // Record ID of the parent record
LookupTableID: Integer, // ID of the target table
ParentLinkFields: Text[1024], // Field numbers in the parent table
LookupTableLinkFields: Text[1024], // Field numbers in the lookup table
LookupTableViewExpression: Text[1024], // Optional filter expression
LookupTableViewValues: Text[1024] // Values for the filter expression
): Text[1024] // Returns Record ID as text
🧾 2. GetFieldValue
This function retrieves a specific field value from a record using its Record ID and field number:
GetFieldValue(
RecIDText: Text[1024], // Record ID of the target record
FieldNo: Integer // Field number to retrieve
): Text[1024] // Returns the field value as text
To refer to the current record, use the keyword This
.
💡 Detailed Example: Item Translation from Table 36
This expression is used to retrieve a translated item description from the Item Translation table (T30), based on the current item, variant, and customer language.
GetFieldValue(LookupRecord(This, 30, '6,5402', '1,5400', 'Field2=1(%1)',GetFieldValue(LookupRecord(This,36,'3','3','',''),41)),3)
🧱 Breakdown of the Expression
🔹 Step 1: Inner Lookup
GetFieldValue(LookupRecord(This,36,'3','3','',''),41)
- Table 36 = Sales Header
- Field 3 = Document No.
- This retrieves the Sales Header record that matches the current line.
- Field 41 = Sell-to Customer No.
- ✅ This part returns the Sell-to Customer No. for the current document.
🔹 Step 2: Outer Lookup
LookupRecord(This,30,'6,5402','1,5400','Field2=1(%1)', <CustomerNo>)
- Table 30 = Item Translation
- Fields 6, 5402 = Item No. and Variant Code (from current record)
- Fields 1, 5400 = Corresponding fields in Table 30
- Filter:
'Field2=1(%1)'
applies a condition where Field 2 (likely Language Code) equals the customer number - ✅ This part returns the Item Translation record for the current item and customer language.
🔹 Step 3: Final Value Retrieval
GetFieldValue(..., 3)
- Field 3 in Table 30 = Translated Description
- ✅ This returns the translated item description if available.
✅ What It Returns
The full expression returns the translated item description for the current item and variant, based on the language associated with the Sell-to Customer on the Sales Header.
If no translation is found, the system may fall back to the default item description.
💡 Example: Item Translation from Table 111
GetFieldValue(LookupRecord(This, 30, '6,5402', '1,5400', 'Field2=1(%1)', GetFieldValue(LookupRecord(This,110,'3','3','',''),41)),3)
This expression retrieves the translated item description if available; otherwise, it falls back to the default.
💡Example: Dimension Value Lookup from Table 480
To retrieve the dimension value name (field 6) from table 480 based on the current record in table 112:
Value := GetFieldValue(LookupRecord(This, 480, '480', '1', 'Field2=1(%1)', 'YEAR'),6)
This links the current record’s “Dimension Set ID” to table 480 and filters by the hardcoded dimension code 'YEAR'
.
💡Example: Customer Item Cross Reference on Sales Order Lines (T37 and T113)
GetFieldValue(LookupRecord(This, 5777, '6,5402,5407,2', '1,2,3,5', 'Field4=1(%1)', '1'),6)
Explanation:
6
= Item No.2
= Customer No.5402
= Variant Code5407
= Unit of Measure Code
Table 5777:1
= Item No.2
= Variant3
= Unit
💡Example: Dimension Value (e.g., "PROJECT")
GetFieldValue(LookupRecord(LookupRecord(This, 480, '480', '1', 'Field2=1(%1)', 'PROJECT'),349, '2,3', '1,2', '', ''),3)
Replace "PROJECT"
with the desired dimension code.
💡Example: Barcode / EAN from Item Cross Reference (T5717)
GetFieldValue(LookupRecord(This, 5717, '6,5402,5407', '1,2,3', 'Field4=1(%1)', '3'),6)
💡Example: Country of Origin
GetFieldValue(LookupRecord(LookupRecord(This, 27, '6', '1', '', ''),9, '95', '1', '', ''),2)
💡Example: Tariff No. Name
GetFieldValue(
LookupRecord(
LookupRecord(This, 27, '6', '1', '', ''),
260, '47', '1', '', ''
),
2
)
💡Example: Length (from T5404)
GetFieldValue(LookupRecord(This, 5404, '6,13', '1,2', '', ''),7300)
💡Example: Job Task No. from T113
GetFieldValue(
LookupRecord(This, 1001, '45,1001', '1,2', '', ''),
3
)
💡Example: Document Header (T112)
For What | Command Line |
---|---|
Job No. on first sales line | GetFieldValue(LookupRecord(This,113,'3','3','',''),45) |
Job Name from first line | GetFieldValue(LookupRecord(LookupRecord(This,113,'3','3','',''),167,'45',1,'',''),3) |
Payment Method Code | GetFieldValue(LookupRecord(This,466,'104','1','Field2=1(%1)',GetFieldValue(LookupRecord(This,112,'3','3','',''),41)),3) |
💡Example: Shipment Method on Sales Shipment (T110)
GetFieldValue(LookupRecord(This, 463, '27', '1', 'Field2=1(%1)', GetFieldValue(LookupRecord(This,110,'3','3','',''),41)),3)
💡Example:
External Document No. from Sales Order to Open Warehouse Shipment (T36)
GetFieldValue(LookupRecord(This, 36, '4,6', '1,3', '', ''),100)
Note: T36 has a two-field primary key: Document Type and Document No., which requires LookupRecord
.
💡 Example: Simple Two-Key Lookup
GetFieldValue(LookupRecord(This, 1001, '45,1001', '1,2', '', ''),3)
Explanation:
This
: Refers to the current line.1001
: Target table.'45,1001'
: Fields in the current record used for linking.'1,2'
: Corresponding fields in the target table.''
: No additional filters.3
: Field number to retrieve.
💡 Example: Multi-Key Lookup with Filter
GetFieldValue(LookupRecord(This, 5717, '6,5402,5407', '1,2,3', 'Field4=1(%1)', '3'),6)
This example demonstrates a more complex lookup using three keys and a filter expression.
Comments
0 comments
Please sign in to leave a comment.