RTB Events API ( rtb_events.p )

Posted by atuldalvi123 on 15-Jan-2016 07:41

Hi All

I am trying to modify existing API rtb_events.p to get object related fields information as below 

IF Pevent = "checkinObjectBefore" THEN DO:

DEFINE VARIABLE hVer AS HANDLE NO-UNDO. 

DEFINE VARIABLE hObj AS HANDLE NO-UNDO.
DEFINE VARIABLE hVerBuf AS HANDLE NO-UNDO.
DEFINE VARIABLE hObjBuf AS HANDLE NO-UNDO.
/* Use Roundtable proxy procedures to get the Object and Version data */
RUN rtb/proxy/p/rtbGetObjectByRowid.p (INPUT Pcontext, OUTPUT TABLE-HANDLE hObj).
hObjBuf = hObj:DEFAULT-BUFFER-HANDLE. hObjBuf:FIND-FIRST.
RUN rtb/proxy/p/rtbGetVersionByRowid.p (INPUT hObjBuf::objVersionRowid, OUTPUT TABLE-HANDLE hVer).
hVerBuf = hVer:DEFAULT-BUFFER-HANDLE.
hVerBuf:FIND-FIRST. /* If not update notes are present, set the error message */
IF hVerBuf::upd-notes = "" THEN DO:
  cError = "Object version update notes cannot be blank!".
  pOk = FALSE.
END.
DELETE OBJECT hVer NO-ERROR.

But here I am not getting task related information such as Task Summary, History, Description.

How do I accomplish this  ?

All Replies

Posted by Jeff Ledbetter on 15-Jan-2016 08:05

You can call rtb/proxy/p/rtbGetTask.p passing hVerBuf::task-num to get the Task Summary and Description.

Posted by atuldalvi123 on 15-Jan-2016 08:55

How can we catch output from this rtbGetTask.p  as we are  passing only input, no output parameters. I do not have rtbGetTask.p file available in progress code only r code is there, so not able to identify the actual structure of this file.

Posted by cverbiest on 15-Jan-2016 09:18

Looking at the rcode I'd say it's also an output table handle.

Not the nicest way to get info, but sometimes it helps.

Posted by Jeff Ledbetter on 15-Jan-2016 09:24

It is indeed a table-handle like the other proxy calls in your example.

Posted by atuldalvi123 on 15-Jan-2016 09:38

Thanks guyz its running now but what i found here that hVerBuf::task-num field has wrong value, it is not the same task no  that i am completing. For e.g. I am closing task no 100 but i am receiving task no 35 in that field. I am catching all these in 'CompleteTaskBefore' event.

Posted by cverbiest on 15-Jan-2016 09:44

In my code I do a find last on rtb_ver but I work directly on the database so there could be a difference between the db table and the temp-table

    find rtb_object where rowid(rtb_object) = to-rowid(pcontext) no-lock.
    find last rtb_ver of rtb_object no-lock.

    find rtb_task where rtb_task.task-num = rtb_ver.task-num no-lock.

Posted by Jeff Ledbetter on 15-Jan-2016 09:52

Each Version is associated with a specific Task (as Carl's direct db example shows). However, direct DB access is discouraged and not supported unless specify directed by a tech support engineer.

A description of your what you want to accomplish with the hook would be helpful. Others may have already written what you are trying to do.

Posted by atuldalvi123 on 15-Jan-2016 09:55

I changed it to find last but still not able to find the actual task no, showing wrong task no. My code is as below

IF Pevent = "completetaskbefore" THEN

   DO:

     RUN rtb/proxy/p/rtbGetObjectByRowid.p

           (INPUT Pcontext, OUTPUT TABLE-HANDLE hObj).

       hObjBuf = hObj:DEFAULT-BUFFER-HANDLE.

       hObjBuf:FIND-FIRST.

       RUN rtb/proxy/p/rtbGetVersionByRowid.p

           (INPUT hObjBuf::objVersionRowid, OUTPUT TABLE-HANDLE hVer).

       hVerBuf = hVer:DEFAULT-BUFFER-HANDLE.

       hVerBuf:FIND-LAST.

      message   rtb_ver.task-num view-as alert-box.    

       /********/

       RUN rtb/proxy/p/rtbGetTask.p

           (INPUT hVerBuf::task-num, OUTPUT TABLE-HANDLE hTsk).

       hTskBuf = hTsk:DEFAULT-BUFFER-HANDLE.

       hTskBuf:FIND-FIRST.

       DO i = 1 TO hTskBuf:NUM-FIELDS:

               MESSAGE hTskBuf:BUFFER-FIELD(i):NAME hTskBuf:BUFFER-FIELD(i):BUFFER-VALUE VIEW-AS ALERT-BOX.

       END.

       /*********/

   END.

I want to read the actual task no, summary and description dynamically.

Posted by Jeff Ledbetter on 15-Jan-2016 09:59

There is no context passed to the completeTaskBefore event. Please review the comments in the header of rtb_events.p.

Posted by atuldalvi123 on 18-Jan-2016 03:51

thanks. its working now.

This thread is closed