In the actions that we created (ZBRD and ZBRDAY) we have standard processing files. Let's write the code for these files.
We create the file ZBRDSTD (standard processing file for the ZBRD action) and put the following code in it:
$ACTION
Case ACTION
When "OUVRE" : Gosub OUVRE
When "DEBUT" : Gosub DEBUT
Endcase
Return
$OUVRE
If clalev([AIN])=0 : Local File CONTACTCRM [AIN] : Endif
Return
$DEBUT
For [AIN] Where day(CNTBIR)=day(date$) & month(CNTBIR)=month(date$)
[M:ZBRD]CNTFNA([M:ZBRD]NBLIG)=[F:AIN]CNTFNA
[M:ZBRD]CNTLNA([M:ZBRD]NBLIG)=[F:AIN]CNTLNA
[M:ZBRD]NBLIG+=1
Next
Affzo [M:ZBRD]
Return
Case ACTION
When "OUVRE" : Gosub OUVRE
When "DEBUT" : Gosub DEBUT
Endcase
Return
$OUVRE
If clalev([AIN])=0 : Local File CONTACTCRM [AIN] : Endif
Return
$DEBUT
For [AIN] Where day(CNTBIR)=day(date$) & month(CNTBIR)=month(date$)
[M:ZBRD]CNTFNA([M:ZBRD]NBLIG)=[F:AIN]CNTFNA
[M:ZBRD]CNTLNA([M:ZBRD]NBLIG)=[F:AIN]CNTLNA
[M:ZBRD]NBLIG+=1
Next
Affzo [M:ZBRD]
Return
In the opening OUVRE action we make sure that the CONTACTCRM table is opened. That is the Contacts (relationship) table. Then, in DEBUT we loop through the records in this table for whom the day and month of their birthday (CNTBIR field) is equal to today's day and month (date$ always contains today's date). After that we display the whole screen with the Affzo instruction.
Next we create the file ZBRDAYSTD (standard processing file for the ZBRDAY action) and put the following code in it:
Subprog BRDAY()
If clalev([AIN])=0 : Local File CONTACTCRM [AIN] : Endif
Filter [AIN] Where day(CNTBIR)=day(date$) & month(CNTBIR)=month(date$)
If rowcount([AIN])>0
Filter [AIN]
Local Char SAVACT(GLONACT)
Local Integer FLGEXE
SAVACT=GACTION
Local Char VALBOUT(250), PARBOUT(250)(1..20)
FLGEXE=1
GACTION="ZBRD"
Call SAISIE_CHAR(VALBOUT, PARBOUT, "ZBRD", "ZBRDSTD", "") From GSAISIE
GACTION=SAVACT
Else
Filter [AIN]
Endif
End
If clalev([AIN])=0 : Local File CONTACTCRM [AIN] : Endif
Filter [AIN] Where day(CNTBIR)=day(date$) & month(CNTBIR)=month(date$)
If rowcount([AIN])>0
Filter [AIN]
Local Char SAVACT(GLONACT)
Local Integer FLGEXE
SAVACT=GACTION
Local Char VALBOUT(250), PARBOUT(250)(1..20)
FLGEXE=1
GACTION="ZBRD"
Call SAISIE_CHAR(VALBOUT, PARBOUT, "ZBRD", "ZBRDSTD", "") From GSAISIE
GACTION=SAVACT
Else
Filter [AIN]
Endif
End
In this file we filter the CONTACTCRM table to check if we have some contacts whose birthday is today. If we do, we setup and use the SAISIE_CHAR function to call the ZBRD action. As you remember, we cannot use an action that displays a window in a workflow, so we use this two-step procedure - we have an action that is going to popup the birthday reminder on the screen and another action to call the first one. So that is what we just programmed.
The last thing left to do is setup the workflow. So we go to the Workflow rules function (GESAWA) and create and validate the following workflow:
General tab:
Recipients tab: Create only one line, leave all fields empty or with the value of No, except for Type and Recipients:
Action tab:
As you can see, the workflow has Event type: Miscellaneous and Event code: CON. This means that it is going to be executed whenever a user connects to X3. And we have checked the Trigger action checkbox, so the workflow will run the action that we specify in the Action tab - which is our ZBRDAY action, which is going to run our ZBRD action, which is going to display the birthday reminder popup. Maybe a bit complicated... but it works like a charm!
So now when we login to X3, if there are business contacts whose birthday is today, we will see something like this:
Of course, other fields can be added as well - for example, a phone number, so that we can call the contact right away and say Happy birthday!
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.