Modifying fields in OnInsert trigger using RecordRef

2»

Comments

  • ajhvdbajhvdb Member Posts: 672
    rocatis wrote:
    Let me quote the online help:

    Are you sure the help is correct?

    You want to transfer the rec to a recref, change some fieldvalues, and move the recref to rec?

    SET and GET does this, but maybe it's not my day and I don't get it. :-$
  • XypherXypher Member Posts: 297
    Even if SETTABLE (through RecRef) worked as intended it would not work for this situation since he is attempting to modify a record that hasn't officially been created yet.
  • rocatisrocatis Member Posts: 163
    ajhvdb wrote:
    rocatis wrote:
    Let me quote the online help:

    Are you sure the help is correct?

    :evil: :evil: :evil: :evil:

    NO! Man, that's just plain idiotic! I can't believe I've wasted half a day because the online help is in error... :roll:

    You're of course right: SETTABLE does exactly what I need.

    My code now looks like this:
    RecRef.GETTABLE(Rec);
    FunctionThatDoesStuff(RecRef);
    RecRef.SETTABLE(Rec);
    

    And it works...
    SET and GET does this, but maybe it's not my day and I don't get it. :-$

    Oh, you're getting it alright - and so is the guy that wrote that online help if I ever get my hands on him :x

    THANKS A LOT!
    Brian Rocatis
    Senior NAV Developer
    Elbek & Vejrup
  • rocatisrocatis Member Posts: 163
    Xypher wrote:
    Even if SETTABLE (through RecRef) worked as intended it would not work for this situation since he is attempting to modify a record that hasn't officially been created yet.

    GETTABLE and SETTABLE works in the same way as TRANSFERFIELDS: it's not a prerequisite that the record actually exists in the database. They just transfer field values.
    Brian Rocatis
    Senior NAV Developer
    Elbek & Vejrup
  • XypherXypher Member Posts: 297
    Shrug, I just remember SETTABLE not working (specifically with transferring filters)...
    lRecRef.GETTABLE(MyTable);
    
    FOR i := 1 TO lRecRef.FIELDCOUNT DO BEGIN
      lFieldRef := lRecRef.FIELD[i];
      lFieldRef.SETFILTER(lFieldFilter[i]);
    END;
    
    lRecRef.SETTABLE(MyTable);
    

    But that didn't work, so I had to resort to using...
    MyTable.SETVIEW(lRecRef.GETVIEW);
    
  • DenSterDenSter Member Posts: 8,305
    rocatis wrote:
    GETTABLE and SETTABLE works in the same way as TRANSFERFIELDS: it's not a prerequisite that the record actually exists in the database. They just transfer field values.
    I was going to suggest that 2 pages ago but kind of assumed that you had actually tried that already :-k funny how you can overlook the simplest things for a long time.
Sign In or Register to comment.