Display Buttons for specific Roles 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.
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 some specific roles.
Code
This example draws a button "Convert to incident" only for roles Administrator, Level 1 Analyst and Service Desk Manager. You can place it anywhere into detail_cr.htmpl page.
var role_list_txt = <PDM_FMT ESC_STYLE=C PAD=NO>"$SESSION.ROLE_LIST"</PDM_FMT>; var role_list = role_list_txt.split( "@,@" ); if (role_list.length > 2) { var roleName = ''; for (var i=1; i<role_list.length; i+=2) { if (role_list[i] == $SESSION.ROLE_ID) { roleName = role_list[i-1]; break; } } if (roleName == 'Administrator' || roleName == 'Level 1 Analyst' || roleName == 'Service Desk Manager') { var popupURL = '$cgi?SID=$SESSION.SID+FID=' + fid_generator() + '+FACTORY=cr+PERSID=$args.persistent_id+OP=UPDATE+ACTIVITY_LOG_TYPE=FLD+HTMPL=act_chgtype_cr.htmpl'; <PDM_MACRO NAME=button CAPTION="Convert to incident" ID=convert_to_incident FUNC="popupActivityWithURL(popupURL, 'crtype')" WIDTH=180 NEWROW=yes ENDROW=yes> } }
This example works only on SD R12!!!






