Product Information
How to add validations in electronic formats using the Electronic File Manager
Introduction:
The SAP Business One Add-on Electronic File Manager Format Definition (EFM) can import the structure (Target) for the Electronic Format for electronic documents type xml from one schema file (xsd), or from an existing xml file.
EFM import target
You cannot edit or delete the validations that come from the schema using the EFM add-on, which makes sense to keep the validations that had an external origin. For that you need to create a new schema xsd and import it again.
But what If the validations imported are too generic for my needs?
Can I add additional Validations?
You can create additional validations with the EFM add-on.
The additional validations can be edited or removed in the add-on, saving you the time an effort of creating a new schema xsd.
In this example:
The original schema (xsd) file has brought to my electronic format the Target element CustomerName: with a definition type= xs:string.
xsd validation
Using EFM I have done a direct mapping, linking the Target node CustomerName to the Source field CardName, which is the Business Partner Name shown in the Invoice.
CustomerName->CardName (direct mapping).
If I wanted to have an additional validation to accept up to 50 characters when processing the xml I can add and additional validation using the Add-on EFM, I don’t need to change or create the xsd file and import it again, by following these steps:
STEPS:
1- In the Validation tab of the target field Mapping Settings where I want my validation, I press the ‘add’ button to unfold the type of validation desired. In my example I will use ‘Length’.
Validation: Add. Select: Length.
2-Then I enter the parameters for my validation.
Validation parameters
In my example I aim to avoid more than 50 characters in the string or leaving it empty.
I enter my Length Range From 1 To 50.
I mark as ‘Error’, to stop the xml file being generated. You can set it as a ‘Warning’, but that will defeat the purpose.
Finally, I define the message that I want to see in SAP Business One as an Error System Messages when the validation fails.
See the syntax in the example:
format(‘”CustomerName” – Value “{0}” exceeds 50 characters’, .)
Syntax:
format
( [open parenthesis]
‘ [single quotation mark]
“ [Double quotation mark] + your free text+ [Double quotation mark]
value “{0}” the variable content inserted in the text of your message.
more free text to be shown after the variable.
‘ [single quotation mark] the end of your text
, [comma]
. [dot] stands the content for the variable value “{0}”, to be captured in the node
)[close parenthesis] to finish your message.
NOTE:
You can create more sophisticated validations using a Customize validation using expressions and functions (see more in the EFM Help File to find functions).
Your expression should be set in a positive or true manner, meaning that you need to define the pattern that meets the validation as true for the error or warning to happen when the pattern is not met/false.
The same example as above, avoiding longer that 50 could be set with this expression:
Expression Function string-length(.) Less than or equal Constant Value 50
Customized
How can I convert dollars to cents?
Hi Blessing
Your question relates more to mapping settings, not to validations.
I recommend to check the part related to Functions in the online help, for example you will find a function called multiply in Functions Number
Here I quote the online help (F1) when running the add-on EFM
multiply(number, number, number?)
Description: Returns the product of the arguments
Sample:
multiply(1, 2, 3) = 6
so you may set if you use 'direct' mapping a function like
multiply(.,100)
And combine it with function round to get rid of the decimals, because you don't want decimals of cents.
round((muliply(.,100))
Apparently I have a function that I have made, it works on bottom lines but on transactional lines it doesnt work. Not sure why. If you have some demo BPP file please send me.
Apparently I have a function that I have made, it works on bottom lines but on transactional lines it doesnt work. Not sure why. If you have some demo BPP file please send me.
Regards
How is can we add custom fields to our EFM definitions?
E.g.
- UserText from the OITM table
- Custom FromDate and ToDate for Line Items
I tried the following but it doesn't work..

Custom Fields