Topic
  • 4 replies
  • Latest Post - ‏2013-05-10T07:10:49Z by raj_kgdr
pinchu
pinchu
14 Posts

Pinned topic Permission hook on Remove button for parent/child hierarchy

‏2009-12-06T16:34:45Z |
I have a list_view to show Child records on a Parent record that actually has Add, Remove, and New buttons to attach/detach child records to the parent. I want to put a permission hook only on the Remove button that should be only allowed for Clearquest admins...

Has anyone done this before in PERL ? If so, can you share the code ....Thanks in advance.
  • SystemAdmin
    SystemAdmin
    24949 Posts

    Re: Permission hook on Remove button for parent/child hierarchy

    ‏2009-12-07T09:14:02Z  
    Hi,

    You can try to use Pre-Action and Post-Action hooks for button "Remove".

    1. Check user group or privileges and set requiredness in Pre-Action hook
    
    $session = $entity->GetSession(); $has_privilege = $session->HasUserPrivilege ($CQPerlExt::CQ_SUPER_USER); 
    
    if ($has_privilege == 
    
    false) 
    { $entity->SetFieldRequirednessForCurrentAction($fieldname, CQPerlExt::CQ_READONLY) 
    }
    

    2. Return previous value for field requiredness in Post-Action hook
    
    $entity->SetFieldRequirednessForCurrentAction($fieldname, $CQPerlExt::CQ_OPTIONAL)
    
  • pinchu
    pinchu
    14 Posts

    Re: Permission hook on Remove button for parent/child hierarchy

    ‏2009-12-08T05:53:31Z  
    I am getting error after adding the code on the Remove button. Also, it allows all users to click on Remove button, but errors out after clicking. Please advise.
  • SystemAdmin
    SystemAdmin
    24949 Posts

    Re: Permission hook on Remove button for parent/child hierarchy

    ‏2009-12-08T08:25:01Z  
    • pinchu
    • ‏2009-12-08T05:53:31Z
    I am getting error after adding the code on the Remove button. Also, it allows all users to click on Remove button, but errors out after clicking. Please advise.
    Hi,

    Yes, this code do not disable Remove botton, it just restrict user that do not have super user privileges to remove records from field. I using this code on VB (CQ 7.1) and it works:

    1. Pre Action Hook:

    
    Dim sessionObj, perm Set sessionObj = GetSession perm = sessionObj.HasUserPrivilege(AD_SUPER_USER) If perm = False Then SetFieldRequirednessForCurrentAction 
    "ActivitiesRelated", AD_READONLY End If
    

    2. Post Action Hook:
    
    SetFieldRequirednessForCurrentAction 
    "ActivitiesRelated", AD_OPTIONAL
    


    That error you getting?
  • raj_kgdr
    raj_kgdr
    63 Posts

    Re: Permission hook on Remove button for parent/child hierarchy

    ‏2013-05-10T07:10:49Z  
    • pinchu
    • ‏2009-12-08T05:53:31Z
    I am getting error after adding the code on the Remove button. Also, it allows all users to click on Remove button, but errors out after clicking. Please advise.

    hi Pinchu,

    If you still there here, can you please share your code. I am in a same situation and need some advice or solutions on this please.

     

    Thanks,

    Raj