Validating field length in Connectivity Studio

Jun 2, 2016 4:25:09 PM

Validating field length in Connectivity Studio

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 To-Increase 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:

// validat 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.

Connectivity Studio validates field length - 1

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 Documentin 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.

Connectivity Studio validates field length - 2

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 To-Increase.

Share this message
About Author
Pieter de Jong

Pieter de Jong

Business and Application Integration Specialist Pieter translates the business requirements of the industries and companies To-Increase serves into functionality in our Business Integration Solutions for Microsoft Dynamics AX. His specialized skills include model-driven development, Javascript, Java, HTML, XML, Visual Studio, and Eclipse. Before Pieter joined the team at To-Increase, he spent a career of close to 20 years as a software engineer and developer at Baan Info Systems and in other companies.

Get In Touch

Related Blogs

Oct 31, 2019 9:54:07 AM
Oct 7, 2019 1:40:55 PM
Aug 8, 2019 11:07:10 AM