Conditional rule to address security location on employee record

Sort:
You are not authorized to post a reply.
Author
Messages
Alex Shklovsky
Basic Member
Posts: 11
Basic Member
    I'm trying to write a conditional rule on HR11.1 to restrict users from accessing employee records based on security location(SEC_LOCATION).  Here is what I got so far 
    if(trim(getDBField('EMPLOYEE', 'SEC_LOCATION', form.EMP_COMPANY, form.EMP_EMPLOYEE))== 'OCE' || 'OCEDRE' )
    'ALL_ACCESS',
    else
    'NO_ACCESS'

    OCE and OCEDRE actual security locations attached to an employee record that user can see. Getting security
    violation on all records. I'm new to LS. What I'm doing wrong?
    Thanks,
    Alex
    John Henley
    Senior Member
    Posts: 3348
    Senior Member
      I think your JavaScript is invalid for the OR "||", and you need to repeat the left side, e.g.

      if(
      trim(getDBField('EMPLOYEE', 'SEC_LOCATION', form.EMP_COMPANY, form.EMP_EMPLOYEE))== 'OCE' ||
      trim(getDBField('EMPLOYEE', 'SEC_LOCATION', form.EMP_COMPANY, form.EMP_EMPLOYEE))== 'OCEDRE'
      )

      Or more ideally, for performance, use a variable:

      var locat = trim(getDBField('EMPLOYEE', 'SEC_LOCATION', form.EMP_COMPANY, form.EMP_EMPLOYEE));
      if(locat== 'OCE' || locat == 'OCEDRE' )
      Thanks for using the LawsonGuru.com forums!
      John
      Alex Shklovsky
      Basic Member
      Posts: 11
      Basic Member
        Thanks a lot Jonh. I've tried with a single value like this:
        if(
        trim(getDBField('EMPLOYEE', 'SEC_LOCATION', form.EMP_COMPANY, form.EMP_EMPLOYEE))== 'OCE'
        ALL_ACCESS
        else
        NO_ACCESS
        Still getting security violation on records that should be opened to that user.
        John Henley
        Senior Member
        Posts: 3348
        Senior Member
          You said:
          Still getting security violation on records that should be opened to that user.
          Your rule is based on the sec location of the employee not a user. Is that correct?
          Thanks for using the LawsonGuru.com forums!
          John
          John Henley
          Senior Member
          Posts: 3348
          Senior Member
            You said:
            Still getting security violation on records that should be opened to that user.
            Your rule is based on the sec location of the employee. Is that correct?
            Thanks for using the LawsonGuru.com forums!
            John
            Alex Shklovsky
            Basic Member
            Posts: 11
            Basic Member
              Yes, This is correct.
              Alex Shklovsky
              Basic Member
              Posts: 11
              Basic Member
                Hi Jonh. I've just started exploring LS and any help would be really appreciated. Would you point me where should I look to resolve this issue. In LAUA it was simple. We had SECURITY_LOCATION defined in HR12 and then it was reflected in LAUA upon security class record level security. Worked like a charm.
                For some reason conditional rule I wrote gives a security violation to all records.
                Thanks for your help
                Alex
                Alex Shklovsky
                Basic Member
                Posts: 11
                Basic Member
                  I've found what it was. Turned debug on. It was complaining on SEC_LOCATION- could not find it, because it must be like this SEC-LOCATION, as far as field name is concerned in Lawson versus SQL Server.
                  Alex
                  Fork
                  New Member
                  Posts: 1
                  New Member
                    Posted By John Henley on 01/06/2012 12:18 PM
                    I think your JavaScript is invalid for the OR "||", and you need to repeat the left side, e.g.

                    if(
                    trim(getDBField('EMPLOYEE', 'SEC_LOCATION', form.EMP_COMPANY, form.EMP_EMPLOYEE))== 'OCE' ||
                    trim(getDBField('EMPLOYEE', 'SEC_LOCATION', form.EMP_COMPANY, form.EMP_EMPLOYEE))== 'OCEDRE'
                    )

                    Or more ideally, for performance, use a variable:

                    var locat = trim(getDBField('EMPLOYEE', 'SEC_LOCATION', form.EMP_COMPANY, form.EMP_EMPLOYEE));
                    if(locat== 'OCE' || locat == 'OCEDRE' )


                    How do you create the local variable in the javascript?   When I go to edit a rule in Lawson Security Administrator, I only have the option of editing what is inside the if() function and cannot add a var outside the if.

                    Thanks
                    You are not authorized to post a reply.