merry xmas... a fancy question on value-changed

Posted by OctavioOlguin on 24-Dec-2015 16:22

Greetings.

I have a .w uib with miriad of fields.  A browse on left and lots of fileds of that record on right.  I intended to do this, but can't accomplish:

ON LEAVE OF fNombre IN FRAME DEFAULT-FRAME /* Nombre */
    OR LEAVE OF fStatus        
    OR LEAVE OF fSucursal      
    OR LEAVE OF fNomina        
    OR LEAVE OF fNombre        
    OR LEAVE OF fDireccion     
    OR LEAVE OF fCP            
    OR LEAVE OF fColonia       
    OR LEAVE OF fTelefono      
    OR LEAVE OF fCiudad        
    OR LEAVE OF fEstado        
    OR LEAVE OF fRFC           
    OR LEAVE OF fIMSS          
    OR LEAVE OF fCURP          
     ......
    OR LEAVE OF fAfore         
    OR LEAVE OF fEdoCivil      
    OR LEAVE OF fFechaNacim    
    OR LEAVE OF fDepen         
    OR LEAVE OF fSexo          
    OR LEAVE OF fTipoSanguineo 
    OR LEAVE OF fVendedor      
    OR LEAVE OF fComision      
    OR LEAVE OF fSueldoDiario  
    OR LEAVE OF fClave         
    OR LEAVE OF fSueldoAnte    
    OR LEAVE OF fHorario       
    OR LEAVE OF fFechaModi     
    OR LEAVE OF fJornada       
    DO:
        IF SELF:MODIFIED   THEN 
        DO:
            MESSAGE "Modified"
                VIEW-AS ALERT-BOX.
           /*  change buttons and state of options*/
        END.
    END.

....

Is there somehow I can program one trigger?  (I did it once, but used self:handle to get into private-data of the buttons which previously had stored the pk to some other data)

At this point I haven't found some method nor property to compare to :screen-value

greetings!!! and thanks!

All Replies

Posted by OctavioOlguin on 26-Dec-2015 09:41

One solution I gave to this problem, is:

ON ENTRY OF xxx  OR ENTRY OF xxy OR ENTRY of xxz ....  DO:

 ASSIGN SELF:PRIVATE-DATA = STRING(SELF:SCREEN-.VALUE).

END.

And on leave of xxxx  or leave of xxy.....:

IF NOT (SELF:PRIVATE-DATA = STRING(SELF:screen-value)) THEN

       DO:

           MESSAGE "Modified"

               VIEW-AS ALERT-BOX.

     END.

END.

but still, I think there is a much cleaver solution, but I don't know to question the current state of a filed (in the sense of changes)

Thanks!.

Posted by Matt Gilarde on 26-Dec-2015 11:16

Unless I'm misunderstanding what you're trying to do, I think an ANYWHERE trigger will do want you want.

ON ENTRY OF FRAME DEFAULT-FRAME ANYWHERE DO:

   /* Use the SELF handle to see which widget in the frame received the event */

END.

Posted by OctavioOlguin on 26-Dec-2015 13:47

mmmhh. more or less, yes... thanks..

the thing is how can I know that a field was changed by the user.

Knowing which widget is being edited Is found by SELF:NAME or anything you want...

but is there some method or property that shows me the value the filed had before the current editing action...

this way I know I have to take some course of action that corresponds to accept editing, and some more stuff..

Thanks!

Posted by Grant Holman on 29-Dec-2015 02:54

Hi,

I've used an 'ON ENTRY' equivalent trigger that stores the previous value in a variable e.g.:

cPrevVal = SELF:SCREEN-VALUE.

Then compare that in the 'ON LEAVE' e.g.:

IF SELF:SCREEN-VALUE <> cPrevVal etc.

Posted by ske on 29-Dec-2015 06:29

> At this point I haven't found some method nor property to compare to :screen-value

What's wrong with SELF:MODIFIED, like in your own example?

Posted by OctavioOlguin on 30-Dec-2015 08:37

It throws true on every leave of the field, even in the case where just tabbing, that's  it, I never changed the value, and still fires true...  :( ?

Posted by ske on 31-Dec-2015 05:06

> It throws true on every leave of the field, even in the case where just tabbing

When I try it, it works. But I'm on an old version, so I don't know if something might have changed.

But more likely, maybe there is something in the rest of your program that affects the status of the MODIFIED attribute? E.g if you DISPLAY the field when it is already enabled, then MODIFIED becomes TRUE. You can reset MODIFIED before editing by turning off and on the field's SENSITIVE attribute. Or don't enable the field until after you DISPLAY it. (According to the ABL reference.)

This thread is closed