Is the recordref open?

RilRil Member Posts: 6
Am I missing the obvious parameter or function in C/side which would actually allow me to check if a recordref is open?
This to avoid the error from NAV saying RECORDREF variable not initialized.

Hope any one knows or maybe have a workaround other than keeping some parallel index for open or not.

It is needed for a temporary based array where i keep differnt tabels in differnt indexes, though out a process

Index[x,y] may have an open recordref but at runtime i need to check this.
Richard Lindberg

Comments

  • krikikriki Member, Moderator Posts: 9,094
    You can try this:
    -create a new codeunit with a function that accepts a recordreference and function puts it in a global variable.
    -in the OnRun-trigger access the variable so it gives an error if not initialized.

    To control if the variable is initialized :
    -Make a global (cduTestRecordReference) to that new codeunit.
    CLEAR(cduTestRecordReference);
    cduTestRecordReference.SendRecordReference(rerTheRecordReference);
    IF cduTestRecordReference.RUN THEN
      MESSAGE('recordreference is initialized');
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • RilRil Member Posts: 6
    Thank you for your reply - i did already try this approach - how ever in the context im running - i am able to crach the NAS - because NAV - blocks on the execption even though it was catched by the IF cu.run thing.
    So this does not do the trick for me.

    So conclusion is that I have to maintain a persited index keeping track on sets open - and in the same post hope that NAV development reads this and fixes this obvious lack of functionallity in c/side using RecordRef.
    Richard Lindberg
  • MTCMTC Member Posts: 159
    If I understand the question correctly, you want to check if the RecordRef has been initialized to something or not, is that correct?

    If so, this is dirty, but:
    IF FORMAT(MyRecordRef) <> '' THEN
    BEGIN
        ...
        ...
    END;
    
  • krikikriki Member, Moderator Posts: 9,094
    Dirty but very nice!
    Can you create a new topic in the tips&tricks forum with this one?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • RilRil Member Posts: 6
    Thank you MTC - that was exactly it - dirty who cares - c/side on the edge is often dirty, knowing all the dirty trick is what makes the c/side "programmers" world go round.
    :lol:
    Richard Lindberg
  • MTCMTC Member Posts: 159
    kriki wrote:
    Dirty but very nice!
    Can you create a new topic in the tips&tricks forum with this one?

    Sure, will do.
  • svensk.tigersvensk.tiger Member Posts: 31
    comming back to this topic, because i ran into the “The length of the source exceeds the size of the destination buffer” Error with the dirty solution (IF FORMAT(RecordRef) then ... )

    and the kriki-solution (if Codeunit.RUN then ... ) has a small but importend disadvantage: it can't be used in write transactions


    using NAV5 and NAV6 classic.


    are there any other solutions, how to test whether a record-Ref is initialized or not?
    Svensk.Tiger (Henning Möller)
    PASS Multibank Solutions AG
    (Kaum macht man was richtig, schon geht es. / Once you do it right, suddenly it works.)
  • krikikriki Member, Moderator Posts: 9,094
    Tried this on a NAV 2009R2 classic:
    MESSAGE('%1',recref.NUMBER);
    

    and when it is not initialized, it returns 0.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • svensk.tigersvensk.tiger Member Posts: 31
    kriki wrote:
    Tried this on a NAV 2009R2 classic:
    MESSAGE('%1',recref.NUMBER);
    

    and when it is not initialized, it returns 0.


    THX, this is working fine.
    Svensk.Tiger (Henning Möller)
    PASS Multibank Solutions AG
    (Kaum macht man was richtig, schon geht es. / Once you do it right, suddenly it works.)
Sign In or Register to comment.