Skip to Content
Product Information
Author's profile photo Jose Antonio Castillo

How to add validations in electronic formats using the Electronic File Manager


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.

In this blog I want to share with you a handy use of the SAP Business One add-on EFM to include additional user defined validations on a pre-existing electronic format, type XML  that has already embedded validations coming from its schema xsd.


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:


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’, .)



( [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.


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



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Blessing Chivave
      Blessing Chivave

      How can I convert dollars to cents?

      Author's profile photo Jose Antonio Castillo
      Jose Antonio Castillo
      Blog Post Author

      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


      multiply(1, 2, 3) = 6

      so you may set if you use 'direct' mapping a function like


      And combine it with function round to get rid of the decimals, because you don't want decimals of cents.



      Author's profile photo Blessing Chivave
      Blessing Chivave

      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.

      Author's profile photo Blessing Chivave
      Blessing Chivave

      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.



      Author's profile photo Wilberth Jaquez
      Wilberth Jaquez
      Hi Jose Antonio 
      If I have to do a validation that only takes the field defined by the user,
      how could I generate this validation,
      I am checking the length function if it works for me in my case.

      but if I have that doubt for example I have a defined field called U_disc
      that takes the distance traveled and which I want to map in
      my input or original string is for a sat complement in Mexico
      Author's profile photo Pascal Feldmann
      Pascal Feldmann

      How is can we add custom fields to our EFM definitions?
      - UserText from the OITM table
      - Custom FromDate and ToDate for Line Items

      I tried the following but it doesn't work..

      Custom Fields