generate/cbs2.gif Transaction Columns Hook (R-xxITEM.MAC) generate/enh73.jpg


 

The script file must be located in your CAPITAL program directory and must have a file name corresponding to one of the names in the File Table. It is executed just after a transaction column is edited by an operator. The script is not executed if the operator cancels any changes made to the column.

File Table

File Name

Purpose

R-INITEM.MAC

Invoices or stock transfers.

R-POITEM.MAC

Purchase orders.

R-RQITEM.MAC

Requisitions.

R-OEITEM.MAC

Sales order entries.

R-REITEM.MAC

Stock Returns.

R-RPITEM.MAC

Stock Receipts.

R-QUITEM.MAC

Quotations.

Entry Values

Variable

Purpose

Focus

The name of the field column the user has just changed. This is always stored in upper case.

Value1

The contents of the column.

generate/notepad2.gifThis value is always returned as a character string.

Return Values

You must return FALSE if you do not wish to alter the contents of the column. Otherwise the return value will be pasted into the column. (This may include blank or empty characters.)

Comments

The Focus variable will contain the column ID. To view the list of available column ID's, consult the topic: Transaction Columns. Only those columns relating to the particular transaction type will be applicable to the hook.

generate/mistake1.gifDo not use the WriteItemValue() inside this hook. If you wish to change the value of the column, use the Return command to return the value you wish to place in the column.

Example #1

The following script adds the characters 'ABC' to every product code entered in the system.

If Focus == "PCODE"

   Return "ABC" + Value1

Endif

Return FALSE

Example #2

This script hook checks to see if you have entered a quantity of zero against a stock item and warns you if so.

If Focus = "QTY"

   If Val(Value1) = 0 .And. .Not. IsEmpty(ReadItemValue("STOCKID"))

      EchoWarn("You have entered a zero quantity!")

   Endif

Endif

Return FALSE

Example #3

* This script checks to see if the quantity entered in the

* quantity column is greater than zero and if so, warns the

* operator if this will result in the item going into

* negative stock. If this may occur, the operator is prompted

* confirm the action.

If Focus = "QTY"

   Declare cMsg Type Character

   Declare nQty Type Numeric

   nQty := VAL(Value1)

   If nQty > 0 .And. StockGetQuantity(TRUE) < nQty

      cMsg := "This quantity will cause stock levels to go into negative stock. Shortfall = "

      cMsg := cMsg + NTrim(nQty - StockGetQuantity(TRUE)) + ";;"

      cMsg := cMsg + "Do you wish to cancel this entry?"

      If Echo(cMsg, TRUE)

         Return 0

      Endif

   Endif

Endif

Return FALSE

____________________________

Related Topics:

Invoice Post-Saving Hook

Scripting Hooks

Script Programming

Transaction Column Script Functions

Transaction Script Functions



Help Topic Map