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.
You take the following steps:
- Open the Microsoft Dynamics AX 2012 Development Workspace.
- Add a new class called 'BisDocumentTextValidateFieldLength' and extend this class from BisDocumentText.
- Override the method.
- Copy the method readFromConnection from BisDocumentText and paste it into the new readFromConnection.
- 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',
6. Save the class and generate an incremental CIL file.
Change the handler on your text document
You do the following:
- Open the Microsoft Dynamics AX 2012 Workspace
- Navigate to Business Integration Solutions > Common > Connectivity > Documents.
- Select your desired Document in the table.
- In the Document tab in the Action Pane, click Header view in Show.
- 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.
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.