Pieter de Jong Pieter de Jong
Jun 2, 2016 4:25:09 PM

Learn how you can direct Connectivity Studio to meet your requirements and validate field length

Today’s brief tutorial shows you an example of how you can easily adjust STAEDEAN Connectivity Studio for Microsoft Dynamics AX to your business-specific needs.

Sometimes, you may want to validate the length of incoming fields during import. Connectivity Studio does not currently validate field length. However, you can easily gain that functionality by extending a document class. This tutorial describes how you can add field length validation to a text document during import. There are just two parts to this—extending the BisDocumentText and changing the handler for your text document.

Extend BisDocumentText

You take the following steps:

  1. Open the Microsoft Dynamics AX 2012 Development Workspace.
  2. Add a new class called 'BisDocumentTextValidateFieldLength' and extend this class from BisDocumentText.
  3. Override the method.
  4. Copy the method readFromConnection from BisDocumentText and paste it into the new readFromConnection.
  5. Below line 84 insert the following code:

// validate the field length

if (recordField.Type == Types::String &&
strLen(valueString) > recordField.FieldLength)
{
throw error(strFmt('Field \'%1\' exceeds maximum length of %2',
AxFieldName,
recordField.FieldLength));

}

6. Save the class and generate an incremental CIL file.

How to add field length validation to a text document during import

Change the handler on your text document

You do the following:

  1. Open the Microsoft Dynamics AX 2012 Workspace
  2. Navigate to Business Integration Solutions > Common > Connectivity > Documents.
  3. Select your desired Document in the table.
  4. In the Document tab in the Action Pane, click Header view in Show.
  5. In the Custom FastTab select 'BisDocumentTextValidateFieldLength' in the handler.

After you have changed the handler your text document will validate the field lengths and throws an error if a field exceeds the maximum field length.

How to change the handler on your text document in Dynamics AX

Thanks for listening! I hope you are finding this little tutorial helpful in working with Connectivity Studio. If you need more information about the Business Integration Solutions, please contact us. If you have any suggestions for improving the tutorial, please let us know, and we will be happy to incorporate them when we can. Please contact STAEDEAN.

Pieter de Jong Pieter de Jong
TI_LOGO_TI-Logo-color andAXP_365

have now rebranded to

staedean-logo-teal