Custom Activity Triggers for Eclipse

Post Reply
larryl
Posts: 1
Joined: Sun Mar 04, 2018 11:15 pm

Custom Activity Triggers for Eclipse

Post by larryl » Wed May 29, 2019 10:10 am

Activity Triggers in Eclipse work as follows:

The file ENTITY.TRIGGER holds multiple types of records:

Activity Trigger Profiles = start with ATP~ followed by the Trigger number (ex ATP~T001)
Activity Trigger Definitions - start with ATD~ (ex ATD~S002)
Customer / Vendor assigned Triggers - start with entity number followed by the specific Trigger "T” number (ex 22073~T001)

ATP’s define the “Trigger Description” in the Activity Trigger Maintenance screen (Invoice Print, POD Delivery Attachment, etc).
They also define the data passed to the called program in the ATD (OID, GEN, STATUS, ST, BT, etc)
And finally the ATP provides a valid list of ATD’s that can be selected as the action.


ATD’s Define the action take when a trigger has fired.
They also define the available data passed to the ATD from the ATP and the available options for sending the message (Email, Text, etc).
And finally the ATD lists the program called when the trigger is run (ex EMAIL.ATD.S001)

The records for customers and vendors are set up in the Activity Trigger Maintenance Screen and I will not go into the details here as it is not needed.

I find it easier to just copy an existing record to a new one for the ATP and ATD records than it is to create one from scratch.
As Epicor has standard Trigger numbers starting at S001, I recommend starting at S999 and working backwards.


As an example, I want to create a new Activity (S999) for the Trigger of Ship Ticket Print (ATP~T026) to Email just a raw CSV file of the items on a Ship Ticket.

To make this work we first have to add our new S999 to the value 3 (ATD.TYPE) of the existing ATP~T026 (Ship Ticket Print) Trigger.

I use the advanced editor (ae) from TCL for this:

Code: Select all

ae entity.trigger “ATP~T026“  <ENTER>
p <ENTER>
3 <ENTER>
ev <ENTER>
p <ENTER>
i <ENTER>
S999 <ENTER> <ENTER><ENTER>
fi <ENTER>
fi <ENTER>

Also see this quick command reference for AE:

Code: Select all

AE DICT **FILE** (PROMPTED FOR FILE NAME (AKA "TABLE NAME"))
AE DICT **FILE** **RECORD**
AE **FILE** **RECORD**
P = DISPLAY NEXT SCREEN FULL OF INFO
P## = SHOW ## OF LINES
ENTER TO GET THE NEXT LINE

I = INSERT MODE
ENTER ON AN EMPTY LINE QUITS INSERT MODE
` ON AN EMPTY LINE INSERTS EMPTY LINE
T = TOP OF THE RECORD
B = BOTTOM OF THE RECORD
+## ADVANCE ## OF LINES

L "SOMETEXT" = GO TO THE FIRST LINE CONTAINING SOMETEXT
L = REPEAT LAST SEARCH
L##/text = SEARCH WITHIN THE NEXT ## LINES

C = CHANGE
A = APPEND
D = DELETE
D## = DELETE ## OF LINES
R = REPLACE WITH text
R<SPACE> THEN PRESS ENTER WILL CLEAR THE LINE

FI = FILE AND SAVE THE RECORD IN THE FILE
Q = QUITE WITHOUT SAVING
SAVE recname = SAVE COPY OF THE RECORD
SAVE filename recname = SAVE COPY OF RECORD IN FILE

> = MARK BEGINNING OF A BLOCK
< = MARK END OF BLOCK
COPY = MAKE A COPY OF A BLOCK
DROP = DELETE CURRENT BLOCK

EV = EDIT MV AS IF EACH VALUE WAS A SEPARATE LINE
ESV = EDIT MS LINE AS IF EACH SUBVALUE WAS A SEPARATE LINE
CHOOSE Q OR FI TO SAVE CHANGES TO THE MV OR MS RECORD IN EV OR ESV MODE

OOPS = UNDO
^ = TURN ON OR OFF PRINTABLE CHARACTERS
J = JOIN THE CURRENT LINE WITH THE NEXT
Now we need to create a new record for our trigger.
Instead we copy an existing one:

Code: Select all

ae entity.trigger “ATD~S001“ <ENTER>
save “ATD~S999“ <ENTER>
q <ENTER>
And then edit that new record:

Code: Select all

ae entity.trigger “ATD~S999“
p <ENTER>
1 <ENTER>
R E-mail CSV Sales Order <ENTER><ENTER>
4 <ENTER>
R EMAIL.ATD.S999 <ENTER><ENTER>
fi <ENTER>
Since we just told Eclipse the program we want to activate is EMAIL.ATD.S999, we now need to create that program in the program editor.


Code: Select all

         SUBROUTINE (AT.ID,AT.DATA,DOCS.PRD,SREC)
** Version# 20.0002[2] - 08/03/2017 - 08:13am - LARRYL - eclipse
*** V20.0002 Change - Custom Coding FOY715 - 08/03/2017 - LARRYL - eclipse
*** V20.0001 Change - Custom Coding 31740 - 08/02/2017 - BDL - eclipse


*** Subroutine - EMAIL.ATD.S999
*-------------------------------------------------------------------------*
*** Activity Subroutine for all emailing CSV Order Import file
*-------------------------------------------------------------------------*
*** AT.ID, AT.DATA, DOCS.PRD,SREC are Activity - Trigger parameters
*** AT.ID      - Activity Trigger ID (found in ENTTITY.TRIGGER field 1)
*** AT.DATA  1 - ...can be assigned...
*** AT.DATA  2 - CN , Entity ID (value 1 Ship To, value 2 Bill To)
*** AT.DATA  3 - BR , Branch concerning this activity-trigger
*** AT.DATA  4 - OID , Order ID
*** AT.DATA  5 - GEN , Generation (value position)
*** AT.DATA  6 - INV , Invoice number
*** AT.DATA  7 - STATUS, Current Status or Temp Status for document
*** AT.DATA 13 - OID.LIST, For batch printed invoices only
*** AT.DATA 14 - GEN.LIST, For batch printed invoices only
*** AT.DATA 16 - Don't Print MTR flag
*** AT.DATA 17 - Flags indicating if email output is being forced
*** DOCS.PRD   - Document Produced flag
*-------------------------------------------------------------------------*
*** PASSER and EM.DATA For EMAIL.DATA.GET
*** PASSER  1  - Email Address
*** PASSER  2  - Customer Number (e.g. Entity ID)
*** PASSER  3   - Contact ID
*** PASSER  4  - Receipiant Name
*** PASSER  5  - Subject
*** PASSER  6  - Attachment path
*** PASSER  7  - CC, Carbon Copies
*** PASSER  8  - BCC, Blind Carbon Copies
*** PASSER  9  - Flag to Append Body as Append
*** PASSER 10  - Flag that calling program will send the email
*** PASSER 11  - Flag to not call user for prompt
*** PASSER 12  - From Name (domain name will be system defined)
*                If not passed will default to @LOGNAME
*** PASSER 13  - EMAIL.SEND cannot override attachment flag (PASSER<9>)
*** PASSER 14  - If Passer9 (doc sent as append) then this will be the
*                message keyed in by user if need to pass to other pgms.
*** PASSER 15  - User BCC address for copies of EMAIL (from SEC-57)
*** PASSER 16  - User BCC Subject Prefix (from SEC-58)
*** PASSER 17  - ATTACHMENT path/key reference e.g. HOLD.FILE:nnnnn
*** PASSER 31  - Don't Print MTR flag
***
*** EM.DATA  1 - CN Bill To  INIT.BT
*** EM.DATA  2 - CN Ship To  INIT.ST
*** EM.DATA  3 - BRanch  INIT.BR
*** EM.DATA  4 - OID, Order ID
*** EM.DATA  5 - GEN value position of currrent generation of order
*** EM.DATA  6 - Order Status for process
*** EM.DATA  7 - Info only call ... DO NOT SEND EMAIL
*-------------------------------------------------------------------------*
          * When coming from a java process, printer.id is not accurate
          * and it's not needed when logging information about e-mails
          * so we are just going to clear it out to prevent bad data
          * from going into the log.
          IF JAVA.PROC$ THEN
             PRINTER.ID = ""
          END

          ERR.MSG      = ''
          OID          = AT.DATA<4>   ;* OID
          GEN          = AT.DATA<5>   ;* GEN


          MATREAD LED FROM LEDFILE,OID ELSE RETURN
          INVN   = LED(8)<1,GEN> 'R%3'
          ORD.ID = OID:'.':INVN

          EM.DATA      = ''
          EM.DATA<9> = YES  ;* coming from activity trigger

          PASSER       = RAISE(RAISE(SREC<6>))
          PASSER<5>    = 'CSV Import for Order# ':ORD.ID
          PASSER<10>   = YES ;* so EMAIL.DATA.GET will send email
          PASSER<11>   = YES ;* No need to prompt as promts in PASSER
          PASSER<18>   = '.csv'
          PASSER<21>   = PASSER<5>

          * No message entered on Trigger.  Use subject as the message
          IF NOT(PASSER<14>) THEN
             PASSER<14> = PASSER<5>
          END

          * Build the CSV file
          GOSUB BUILD.FILE

          * Send the email
          EMAIL.DATA.GET EM.DATA,PASSER,,ELNS,ERR.MSG
          IF NOT(ERR.MSG) THEN
             DOCS.PRD = YES
             OE.ADD.COMMENT OID,GEN,'CSV Order Import file Emailed to: ':PASSER<1>
          END


          RETURN
*-------------------------------------------------------------------------*
BUILD.FILE:  *


          BT.CN = LED(1)<1,GEN>
          PBR   = LED(2)<1,GEN,1>
          SBR   = LED(2)<1,GEN,1>
          ST.CN = LED(5)<1,GEN>

          READV ALT_CUS FROM ENTFILE,ST.CN,66 ELSE ALT_CUS = ''
          OE.GET.QSIGN QSIGN,OID,GEN

          LDIDS = LED(48)<1,GEN>
          CONVERT SVM TO AM IN LDIDS
          LD.CT     = DCOUNT(LDIDS,AM)

          HROW     = 'Qty'
          HROW<2>  = 'UOM'
          HROW<3>  = 'CustomerPartNumber'
          HROW<4>  = 'ProductID'
          HROW<5>  = 'Description'
          HROW<6>  = 'Unit Price'
          HROW<7>  = 'Extended Price'
          HROW<8>  = 'Pricing UOM'
          HROW<9>  = 'Pricing Qty'
          CONVERT AM TO VM IN HROW
          ELNS     = HROW

          FOR LDC  = 1 TO LD.CT
             LDID  = LDIDS<LDC>
             LD.GET LDID

             PN  = LD(1)

             * Skip comments
             IF NOT(NUM(PN)) THEN CONTINUE

             QS  = (SUM(LD(5)<1,GEN>) + SUM(LD(6)<1,GEN>)) * QSIGN
             UOM = LD(23)

             OE.CUS.PN.CMT.GET BT.CN,ST.CN,ALT_CUS,PN,CMT
             CPN =  CMT<1>

             GET.ALL.PRD PBR,PN,-1
             PRICE.PER.GET PER.QTY,PER.UM,,,LED(22)<1,GEN>

             READV DESC FROM PRDFILE,PN,1 ELSE DESC = ''
             CONVERT VM  TO " " IN DESC
             DESC  = TRIM(DESC)

             UPRC  = LD(8)<1,GEN>
             EPRC  = OCONV(ICONV(OCONV(QS*UPRC,'MR9'),'MR2'),'MR2')
             UPRC  = OCONV(ICONV(OCONV(UPRC*PER.QTY,'MR9'),'MR3'),'MR3')

             ELINE    = QS
             ELINE<2> = UOM
             ELINE<3> = CPN
             ELINE<4> = PN
             ELINE<5> = DESC
             ELINE<6> = UPRC
             ELINE<7> = EPRC
             ELINE<8> = PER.UM
             ELINE<9> = PER.QTY

             ELNS<-1> = LOWER(ELINE)
          NEXT LDC

          CONVERT "," TO ";"      IN ELNS
          CONVERT VM  TO ","      IN ELNS

          RETURN
!LARRYL~08/03/17~08:13

Now it is just a matter of adding the trigger to the customer record.

Post Reply