Check if a record is in an editable state

SOLVED

I'm working on a button script where I'll be looping through multiple Sales Orders, and sometimes an SO will be locked (e.g. when it has an invoice being processed).

oSalesOrder = oSession.GetObject("SO_SalesOrder_bus")
Set oSalesOrder = oSession.AsObject(oSalesOrder)
retVal = oSalesOrder.MoveFirst()
do until oSalesOrder.EoF
...

What I'd like to do is check if the record is read only, before starting into the business logic.

EditState only tells me if it is a new / existing record, not whether the record is editable... and I'd prefer to catch this up front (instead of checking for failed write() attempts). 

Does anyone know how to check this when looping using MoveFirst and MoveNext...?

  • +1
    verified answer

    Looks like the retVal on the MoveFirst / MoveNext is 1 when the SO is opened for editing... with 0 / -1 when read-only.

  • 0 in reply to Kevin M

    I was just dealing with something similar.  You can check the following;

    • If the business object's ReadOnlyReason property is set to a non blank value.
    • If the business object's ViewOnly property is equal to 1.
    • If the business object's SecurityAccess property is equal to 0.

    I think Alnoor posted somewhere how to interpret the various values that SecurityAccess can return because it is calculated based on the options selected for the task in Role Maintenance.  What i can say for sure though, is that if it is equal to 0, it is ready only.

  • 0 in reply to David Speck

    Thanks David!  I could remember that post, but not what the property was... a keyword search on my scripting notes found the details.  (I must have copied them at the time).

    oBusObj.SecurityAccess

    if oBusObj.SecurityAccess = 0 then ' Inquiry screen or user only has View permission.

     

    0 equals View only.

    2 equals Modify with View implied.

    3 equals Create with View and Modify implied.

    4 equals Remove with View implied.

    6 equals Modify and Remove with View implied.

    7 equals Create, Modify, and Remove with View implied.