Control - Smart Part CFL Changes

Smart Part Variables

procedure ExecSearch(variable or variableName);

Executes the Part Search on the specified PSV.

If the variable is not a PSV, an error is raised.

procedure AddSearchResultsToOrder(variable or variableName)

Adds the non-zero Quantity search results from a PSV to an order.

If the variable is not a PSV, an error is raised.

procedure UpdateBatchName({oldbatchname}, {newbatchname})

Changes the batch name to NewBatchName for all occurrences of parts in the line item with BatchName=OldBatchName

procedure SetSearchCriteria(variable or variableName, propertyName, newPropertyValue)

Sets the User Search value to newPropertyValue for a given propertyName on the variable or variableName (if the variable is a Part Search Variable).

This is used when a Tab Header control needs to change the search values

function PartTotalQuantity(variable) : integer;

Retrieve the sum(quantity) of the Parts collection from a PSV or PFV.

function PartTotalCost(variable) : integer;

Retrieve the sum(cost) of the Parts collection from a PSV or PFV.

function PartTotalPrice(variable) : integer;

Retrieve the sum(price) of the Parts collection from a PSV or PFV.

function PartAverageCost(variable) : integer;

Retrieve the average(cost) [that is, sum(cost) / sum(quantity)] of the Parts collection from a PSV or PFV where Quantity 0

function PartAveragePrice(variable) : integer;

Retrieve the average(price), [that is, sum(price) / sum(quantity)] of the Parts collection from a PSV or PFV where Quantity 0

function PartCount(variable) : integer;

Retrieve the count(*) of the Parts collection from a PSV or PFV.

function PartByIndex(variable, index) : TTransPart;

Retrieve the referenced part by index from the Parts collection from a PSV or PFV.

Pricing Form

function IsPricingFormDisplayed() : Boolean

Returns True (1) if a pricing form is being displayed when executed.

function IsValidPricingFormComponent({componentname}) : Boolean

Returns True (1) if a component with the specified name exists on the currently displayed pricing form. If the component is not found or a pricing form is not being displayed, it returns False (0).

function GetPricingFormProperty({componentname}, {property}[, {defaultvalue}]) : variant

Returns a published property from the specified component on the currently displayed pricing form. If the component is not found or a pricing form is not being displayed, it returns the default value. If no default value was supplied, it returns the value “Not Available”.

procedure SetPricingFormProperty({componentname}, {property}, {value})

Sets a published property on the specified component on the currently displayed pricing form. If the component is not found or a pricing form is not being displayed, an error is returned.

NOTE:

Setting properties that are pulled from the variable cannot be changed by this function.

For example, a SpinEdit bound to a variable will only use the Value from the variable, it will not persist a change to the Value property via SetPricingFormProperty.

Variables

property OnChange : string

This formula called when the tab changes. The old value and new value are passed into the method by way of declared variables added to the front of the user CFL code, as in:

Declare OldValue := {old value};

Declare NewValue := {new value};

This is very useful for reverting old values, or creating new validation rules, or for setting other variables when this variable changes.

The OnChange formula has been added to variables of these types:

  • Number
  • Text
  • Yes/No
  • List
  • Date Time

Pricing Form Controls

property OnCreate : string

This event is triggered when the form that the TDesignerPageControl is created, but after all other aspects of the pricing form have been initialized. It is usually used to initialize values on the pricing form, such as set the initial tab names for a page control.

property OnActivate : string

This event is called when the PageControl gets focus. This is when the form is created if the PageControl starts with initial focus.

property OnDeactivate : string

This event is called when the PageControl looses focus. This is called before the form is closed if the PageControl had focus at the time.

Tab Controls

property OnTabChange : string

This event is called when the tab changes. The name of the current and new tab are passed into the method by way of declared variables added to the front of the user CFL code, as in:

Declare OldTab := “{old tab name}”;

Declare NewTab := “{new tab name}”;

The user has no ability to stop or change the tab flow. This event is not called during the initial creation of the TDesignerPageControl.

Combo Box Controls

procedure OnDropDownFormula : string

This event is called when the combo box prepares for a drop-down. The values of the drop down list are passed into the procedure as a semicolon-delimited string using a declared variable added to the front of the user CFL code, as in:

Declare Items := “item1;item2;item3; … ”;

The user can change the list by updating the local Items variable within the CFL routine.

The OnChange formula, when coupled with the SetPricingFormProperty and GetPricingFormProperty CFL functions allows a user to dynamically change a component's values in order entry.

To illustrate this ability, let's do a quick example. Our goal will be to have a text input change out the captions of a Tab Header Control.

Variable Setup

  1. Create a variable for the 'setter' input. (example: “TabHeaderSetter”)
  2. Set its type to 'Text'
  3. Add a default value (example: “DefaultVal”)

Pricing Form Setup

  1. Create a new pricing form or open an existing form
  2. Put a new text input control on the form
  3. Set the Variable Name property of the new text input to the 'setter' variable (in our example “TabHeaderSetter”)
  4. Put a new tab header control on the form
  5. Set the Name to “DynamicTabHeader”
  6. Set the TabItems string with some tab names separated by a semicolon, and have one of the tab names be the default value from the 'setter' variable (in our example, “DefaultVal”)
  7. Set its DisplayedInfo property to pmdText (so that we don't have to assign a different variable to have it work)

OnChange Variable Setup

  1. Open the 'setter' variable.
  2. Open the 'Action when Value Changes' formula editor
  3. Paste the following formula in and then save
//this is an annotated OnChange formula
//this formula sets the TabItems property on a control named DynamicTabHeader
//please note: all OnChange formulas have two variables declared implicitly: OldValue and NewValue
if IsPricingFormDisplayed() then //if there is a pricing form, then we can use the pricing form property functions
 //we want to get the current TabItems property, replace the old value with the new value, then set that new string as the new TabItems value
 SetPricingFormProperty('DynamicTabHeader', 'TabItems', Replace(GetPricingFormProperty('DynamicTabHeader', 'TabItems', 'Default'), OldValue, NewValue));
endif;

Product Setup

  1. Assign the 'setter' variable from step 1 to a product
  2. Assign the pricing form from step 2 to the same product

Result

We now have a product with a pricing form with a text input that, when changed, will updated one tab header on a TabHeaderControl.

The OnTabChange formula allows a user to have formulas fire when tabs change. This is very similar to the OnChange formula, but the OnTabChange is on a tab control, not a variable. This means a user does not need to bind to a variable to get the event they need.

The usefulness of OnTabChange is very apparent when tied with Smart Part components. Two examples of this follow:

Batch Name Filtering Tabs

The following is a walkthrough on editing the Pricing Form, and assumes the pricing form is assigned to a product with a Part Filter Variable, and that variable is using a FilterMode of BatchName.

  1. Put a Part Filter Grid on the pricing form if it does not already exist, and bind it to the Part Filter Variable
  2. Put a Tab Header Control on the pricing form
  3. Set the DisplayedInfo property on the Tab Header Control to pmdText (to avoid requiring a Variable bound to it)
  4. Open the OnTabChange formula editor
  5. Add the following annotated formula:
//this is an annotated OnTabChange formula
//this formula sets the BatchNameFilter on a Part Filter Variable to the name of the tab
//please note: all OnTabChange formulas have two implicit variables: OldTab and NewTab
SetVariableProperty(PartFilterVariable, 'BatchNameFilter', NewTab);

With this CFL, when a tab changes on the Tab Header Control, the Part Filter Grid will use the tab's name as the Batch filter.

Search Criteria Tabs

The following is a walkthrough on editing the Pricing Form, and assumes the pricing form is assigned to a product with a Part Search Variable. In this example, it sets the Part.SKU search criteria field to the name of the tab being changed to.

  1. Put a Part Search Grid on the pricing form if it does not already exist, and bind it to the Part Search Variable
  2. Put a Tab Header Control on the pricing form
  3. Set the DisplayedInfo property on the Tab Header Control to pmdText (to avoid requiring a Variable bound to it)
  4. Open the OnTabChange formula editor
  5. Add the following annotated formula:
//this is an annotated OnTabChange formula
//this formula changes one search criteria value of a Part Search Variable to the name of the tab
//please note: all OnTabChange formulas have two implicit variables: OldTab and NewTab
//please note: SetSearchCriteria requires the field name (the second parameter) to be already included in the Part Search Variable's User Search.
SetSearchCriteria(PartSearchVariable, 'Part.SKU', NewTab);

With this CFL, when the tab changes, any Part Search Grids or Part Search Builders bound to the specific PartSearchVariable will update to use the new tab as the value of the “Part.SKU” filter.

You could leave a comment if you were logged in.