generate/cbs2.gif Other Transaction Post-Saving Hooks generate/en72.jpg


 

The script file must be located in your CAPITAL program directory and must have a file name matching the contents of the following table:

File name

Transaction

R-ORDTEN.MAC

Sales Order

R-QUOTEN.MAC

Quotations

R-PURTEN.MAC

Purchase Order

R-RECTEN.MAC

Stock Receipts

R-RETTEN.MAC

Stock Returns

R-REQTEN.MAC

Requisitions

R-TRATEN.MAC

*Stock Transfers

*Enterprise & Corporate Edition Only

It is executed after a transaction is saved.

Entry Values

None.

Return Values

None.

Example #1

* Sales Order Script

* Prompt the user for 'home' or 'store' delivery

* and store the resulting selection in the sales

* order Other Reference field.

FormCreate()

FormAdd("Delivery", 1, { "Home", "Store" } )

If .Not. FormShow("Type of Delivery")

   Return FALSE

Endif

If FormResult(1) == 1

   Orders->(Write("OOURREF", "HOME"))

Else

   Orders->(Write("OOURREF", "STORE"))

Endif

Return TRUE

Example #2

* Send an order acknowledgement as soon as

* a sales order is entered in the system.

Declare MyScript Type Character

MyScript := ""

MyScript := MyScript + "Declare FirstTran Type Transaction" + CHR(13) + CHR(10)

MyScript := MyScript + "FirstTran := '" + Orders->Oorderno + "'" + CHR(13) + CHR(10)

MyScript := MyScript + "Declare LastTran Type Transaction" + CHR(13) + CHR(10)

MyScript := MyScript + "LastTran := '" + Orders->Oorderno + "'"

Declare MyFax Type Logical

Declare MySend Type Character

* If the user wants it sent via email check that

* there is an email address (otherwise it will still be

* sent via fax)

If Cuaux000->Conftype = "Y" .And. .Not. IsEmpty(Custrec->Cusemail)

   MyFax := FALSE

   MySend := Trim(Custrec->Cusemail)

Else

   MyFax := TRUE

   MySend := Trim(Custrec->Cusfax)

Endif

* Do nothing if customer wants fax and there is no

* fax number

If IsEmpty(MySend)

   Return

Endif

* Which spooler to send to

Declare MySpool Type Character

MySpool := "EPOST"

CreateEmailJob("Confirm", MySend, "Order Confirmation: " + TranStr(Orders->Oorderno),,,,, MyScript, MySpool,, MyFax)

___________________________

Related Topics:

Credit Limit Check Hook

Other Transaction Pre-saving Hooks

Scripting Hooks

Script Programming



Help Topic Map