Topic
  • 2 replies
  • Latest Post - ‏2013-02-12T07:41:23Z by SystemAdmin
SystemAdmin
SystemAdmin
3180 Posts

Pinned topic Write Access to Attribute

‏2013-02-11T16:11:02Z |
What is the simplest way to determine if it is possible to write to an attribute?

Do i need to check:
(isEdit or (isShare and LockedObject)) and PermissionToAttributeValue

or is there some function that checks everything?
Updated on 2013-02-12T07:41:23Z at 2013-02-12T07:41:23Z by SystemAdmin
  • llandale
    llandale
    2972 Posts

    Re: Write Access to Attribute

    ‏2013-02-11T20:23:04Z  

    The "is it Edit or Shared-and-Locked and do I have rights to object and Attribute" method is complicated and subject to wierd exceptions.

    The "canXX" perms determine if you have rights AND access right now and accurately predict what will happen:

    if (!canModify(obj.NameAttr)) //
    then will fail
    else obj.NameAttr = Value
    


    canModify, canControl, canDelete, canRead

    You can also just trap the errors:

     

    noError()
    obj.NameAttr = Value
    string ErrMess = lastError()
    if (!null ErrMess) //
    then write error
    else success
    


    That is a little better since the first method actually requires you to trap "obj.NameAttr" reference errors.

    -Louie

     

    Updated on 2014-01-06T13:30:06Z at 2014-01-06T13:30:06Z by iron-man
  • SystemAdmin
    SystemAdmin
    3180 Posts

    Re: Write Access to Attribute

    ‏2013-02-12T07:41:23Z  
    • llandale
    • ‏2013-02-11T20:23:04Z

    The "is it Edit or Shared-and-Locked and do I have rights to object and Attribute" method is complicated and subject to wierd exceptions.

    The "canXX" perms determine if you have rights AND access right now and accurately predict what will happen:

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">if (!canModify(obj.NameAttr)) // then will fail else obj.NameAttr = Value </pre>


    canModify, canControl, canDelete, canRead

    You can also just trap the errors:

     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">noError() obj.NameAttr = Value string ErrMess = lastError() if (!null ErrMess) // then write error else success </pre>


    That is a little better since the first method actually requires you to trap "obj.NameAttr" reference errors.

    -Louie

     

    Ah yes, the 'can..s' were what I was looking for.

    Thanks Louie