Display Buttons for Group members only
From SDU
To make corrections or additions to this article, select the edit tab above.
To discuss or ask questions about this article, select the discussion tab above.
Overview
This article describe in example how to simply show a button (or anything else, button code of course can be easily changed) on page only for members of group filled in ticket.
Code
We need to show button Take, which change status from Assigned to Work in progress and set Assignee to logged in user, but this button must be shown only for members of a group filled in ticket. Here is a solution for Incident object, but for change object is the solution very similar:
<PDM_IF "$cst.group_list.length" \> "0">
// check if logged user is in ticket's group
if (false // to prevent || operator as a first literal in command, add this "non-sense" literal (false) to if condition
<PDM_LIST PREFIX="list" FACTORY="grpmem" WHERE="member = U'$cst.id'">
|| '$list.group' == '$args.group'
</PDM_LIST>
) {
// this is ticket on one of my groups and isn't mine, so draw Take/Control button
popupURLtk = '$cgi?SID=$SESSION.SID+FID=' + fid_generator() +
'+FACTORY=cr+PERSID=$args.persistent_id+OP=UPDATE+ACTIVITY_LOG_TYPE=ST+HTMPL=xfer_take_cr.htmpl';
ImgBtnCreate('take', 'Take', "popupActivityWithURL(popupURLtk, 'status')", true, 120);
}
</PDM_IF>