November 2010
M T W T F S S
« Oct   Dec »
1234567
891011121314
15161718192021
22232425262728
2930  
Archives

Extended Composites in Dynamics GP

Hi all

I have been having this topic in mind for long, but finally decided to pen it down. I am sure we all know what a composite field in GP is. “A composite is a group of fields and their associated data types which form a single data type” as the Dexterity Guide explains it.

There are 2 types of composites

  1. Standard Composite
  2. Extended Composite

The standard composite can have up to 9 components with a fixed length for each component.

However, there is another type called the Extended Composite, which is slightly more robust in functionality compared to a standard composite. It can have up to 128 components and can have variable length for each component and the component length can be determined at run time depending on business requirements. A well known example of an extended composite is the Account Number field in GP. Depending on the Account Format Setup, the length of each segment of the account number (which is a component in the composite) can be dynamically configured.

In this article I have planned to give some quick insight into the steps needed to create an extended composite.

Composite Definition

The first step is to identify and setup the composite definition using Dexterity. For this example sake, we will create a composite with 3 components.

First define 2 string fields as explained below.

Component 1 – String Field (10 chars max)

Component 2 – String Field (10 chars max)

Component 3 – String Field (10 chars max)

imageimageimage

Then create a composite field with the 3 fields created above as components.

image

Create a format for the composite as illustrated below. Define the formatting as XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXXX

image

Create a data type for the composite as illustrated below.

image

Create a field with the composite which we have created above as explained below.

image

Command Form for the Composite Property Initialization

Create a form in Dexterity with the following properties.

Form Name – Command_Form

image

Create a window and define the following properties for the window.

Window Name – Dummy

Window Title – ~internal~

AutoOpen – FALSE

image

Add the composite field to the form as shown below and hide the field.

image

Scripting the Command Form

Add the following script to the Form’s PRE event.

{Override the properties of the composite field} 
override field CVA_CompositeField of window Dummy, "-", false; 
 
{Override the properties of the components of the composite} 
override component(1) of field CVA_CompositeField of window Dummy, 4, "W"; 
override component(2) of field CVA_CompositeField of window Dummy, 4, "W"; 
override component(3) of field CVA_CompositeField of window Dummy, 4, "W";

image

The override field statement sets the separator character and specifies whether scroll arrows will appear for the composite field.

The override component statement sets the keyable length of a component in an extended composite. It also specifies the character whose width will be used as the base width for the component. If we specify the length as 0 for a component, the specific component will be disabled in the field. The width_base_character parameter ensures the component has enough room to be displayed. For example, if the component will be displaying only numbers, 9 can be used as the width-base character. If text will be displayed in the component, W can be used since it’s the widest letter.

Create the following script CVA_OpenCommandForm to open the command form.

open form Command_Form;

Create the following script CVA_CloseCommandForm to open the command form.

close form Command_Form;

Create a script called Startup to create triggers to call the scripts created above and open/close the command forms.

if Trigger_RegisterProcedure(script OpenCommandForms,
	TRIGGER_AFTER_ORIGINAL, 
	script CVA_OpenCommandForm) <> SY_NOERR then
	warning "Procedure trigger CVA_OpenCommandForm registration failed.";
end if;
 
if Trigger_RegisterProcedure(script CloseCommandForms,
	TRIGGER_AFTER_ORIGINAL, 
	script CVA_CloseCommandForm) <> SY_NOERR then
	warning "Procedure trigger CVA_CloseCommandForm registration failed.";
end if;

Adding Extended Composite Field to Forms

Create a custom form and add the extended composite to that form and see how it works. It would only allow the appropriate length specified for each component to be entered in the composite for each component.

image

Hope this was helpful to all…

Until next post…

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)