Capturing the Label of a field in a trigger

manujmathew

New Member
I want to capture the LABEL of a field in a variable when I fire a trigger while running a program.
I have used FOCUS:LABEL.
eg:
DEF VAR testvar AS CHAR LABEL "CUSTOMER" NO-UNDO.
ON LEAVE ANYWHERE
DO:
testvar = FOCUS:LABEL.
END.
UPDATE testvar WITH FRAME sframe.
DISP testvar WITH FRAME sframe.

But I want to capture it when I'm using a trigger with Write statement.
eg:
ON WRITE OF table-name
DO:
testvar = FOCUS:LABEL.
END.
RUN test.p.

Here I'm getting run time error 3140.
Is there a solution where I can capture the label in write statement.
 
I want to capture the LABEL of a field in a variable when I fire a trigger while running a program.
I have used FOCUS:LABEL.
eg:
DEF VAR testvar AS CHAR LABEL "CUSTOMER" NO-UNDO.
ON LEAVE ANYWHERE
DO:
testvar = FOCUS:LABEL.
END.
UPDATE testvar WITH FRAME sframe.
DISP testvar WITH FRAME sframe.

But I want to capture it when I'm using a trigger with Write statement.
eg:
ON WRITE OF table-name
DO:
testvar = FOCUS:LABEL.
END.
FIND FIRST pt_mstr EXCLUSIVE-LOCK NO-ERROR.
IF AVAIL pt_mstr THEN
DO:
UPDATE pt_part testvar WITH FRAME sframe.
DISP pt_part testvar WITH FRAME sframe.
END.

Is there a solution where I can capture the label in write statement.
 
Code:
DEF VAR testvar AS CHAR LABEL "CUSTOMER" NO-UNDO.
DEFINE FRAME sfarme
    customer.NAME SKIP
    testvar.
ON WRITE OF customer
DO:
    testvar = FOCUS:LABEL IN FRAME sframe.
    DISP NAME testvar WITH FRAME sframe.
END.
FIND FIRST customer EXCLUSIVE-LOCK NO-ERROR.
IF AVAIL customer THEN 
DO:
    UPDATE NAME WITH FRAME sframe. 
END.
 
IMHO - it is not clear to me what it is you are trying to achieve.

A trigger which fires on WRITE of a table is part of the business logic. Making the business logic dependent of UI functionality is against the idea of separating UI and business logic. Maybe if you would be more clear as to why you need to have the label of a UI widget in your business logic we could give you a better advise.

Heavy Regards, RealHeavyDude.
 
Thanks a lot.But what if there are multiple frames with different frame names.Actually i want to capture all the pt_mstr labels from Item master maintenence program in a particular temp-table field inside a trigger.The enduser wants to keep a track on which pt_mstr fields were updated.Since he doesn't know the fields,for simplicity purposes he wants to know the labels.
 
IMHO - you should not base your logic on UI widgets. Instead you could grab the handle to the buffer and the buffer filed of the Temp-Table or database table and grab the label from there:
DEFINE VARIABLE cLabel AS CHARACTER NO-UNDO.
/* Grab the label for a given field of a given table */
ASSIGN cLabel = BUFFER yourTableName:HANDLE:BUFFER-FIELD ( "yourFieldName" ):LABEL.
Heavy Regards, RealHeavyDude.
 
Back
Top