Work with Recordref and Session table

IuliiaIuliia Member Posts: 3
Session table is a virtual table that also has a different view for Native and SQL Navision.
How to organize work with this table to determine what type of connection current user has.What mistake i do in code?
//Sessin - recordref,MySession,AuthType - fieldrefs.

Session.OPEN(2000000009,FALSE);
MySession := Session.FIELD(SessionRec.FIELDNO("My Session"));
AuthType := Session.FIELD(SessionRec.FIELDNO("Login Type"));
MySession.SETFILTER('YES');
Session.FINDFIRST;
IF FORMAT(AuthType.VALUE) = 'Database' THEN
MESSAGE('database') ELSE
MESSAGE('Windows');

Comments

  • BeliasBelias Member Posts: 2,998
    this is the online help:
    FieldRef.SETFILTER(String [, Value],...)

    in string you put <,>,= etc....
    you should do something like this
    mysession.setfilter('=',true);
    
    or
    mysession.setrange(true);  //Better
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • IuliiaIuliia Member Posts: 3
    I have find solution myself:). The error was found in FORMAT(AuthType.VALUE)....
    Session.OPEN(2000000009,FALSE);
    Session.RESET;
    MySession := Session.FIELD(SessionRec.FIELDNO("My Session"));
    AuthType := Session.FIELD(SessionRec.FIELDNO("Login Type"));
    MySession.SETFILTER('YES');
    Session.FINDFIRST;
    IF FORMAT(AuthType) ='Database' THEN
  • tompynationtompynation Member Posts: 398
    sessionRec.SETRANGE("My Session",TRUE);
    IF sessionRec.FIND('-') THEN BEGIN
    IF sessionRec."Login Type" = sessionRec."Login Type"::Windows THEN
    BEGIN
    lv_WindowsAccessControl.SETRANGE(lv_WindowsAccessControl."Login ID",sessionRec."User ID");
    lv_WindowsAccessControl.SETRANGE(lv_WindowsAccessControl."Role ID",'ITEMMGR');
    IF NOT(lv_WindowsAccessControl.FINDFIRST) THEN
    CurrForm.Obsolete.EDITABLE(FALSE);
    END
    ELSE
    BEGIN
    GVMemberOf.SETRANGE(GVMemberOf."User ID",sessionRec."User ID");
    GVMemberOf.SETRANGE(GVMemberOf."Role ID",'ITEMMGR');
    IF NOT(GVMemberOf.FINDFIRST) THEN
    CurrForm.Obsolete.EDITABLE(FALSE);
    END;
    END;
  • BeliasBelias Member Posts: 2,998
    Belias wrote:
    this is the online help:
    FieldRef.SETFILTER(String [, Value],...)

    in string you put <,>,= etc....
    you should do something like this
    mysession.setfilter('=',true);
    
    or
    mysession.setrange(true);  //Better
    
    forget this :whistle:
    i read the help partially :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.