Lock down change states for users with change_management role

ebaileyybs
Tera Expert

Hi,

I am looking to lock down certain states available for selection within the change state field. Please see below options;

find_real_file.png

I would like for 'ITIL' users to only be able to select the following states;

Draft

Review

Closed

Users with the change_management role should be able to select any of the above states.

Any help with this would be greatly appreciate.d

Kind regards,

Emma

35 REPLIES 35

Kalaiarasan Pus
Giga Sage

You would need a onload client script or a UI policy and add or remove the options using g_form methods...



This should help



GlideForm (g form) - ServiceNow Wiki


I just implemented a similar requirement and here's the code from my Client Script.


I thought about changing it to meet your requirements, but then I have the risk that I miss something.


So, I am assuming that you can make the necessary adjustments to handle your situation.


If there's something not quite right, let me know.   ( I wish I new how the experts paste in code that looks professional, maybe when I'm up to their level )



function onLoad() {


    //If you're not a change manager and the approval is NOT CAB Approved, limit state options to Draft, Submitted or Cancelled


    // ie. disallow   WIP_PAT(5), WIP_PROD(6), Scheduled(2), Closed(8), Executed_Successfully(3), Executed_part_fail(4), Executed_fail(9)




    if ( !g_user.hasRole('Change Manager') && ( g_form.getValue("approval") != "cab approved" ) )


    {


            g_form.removeOption('state', 5);


            g_form.removeOption('state', 6);


            g_form.removeOption('state', 2);


            g_form.removeOption('state', 8);


            g_form.removeOption('state', 3);


            g_form.removeOption('state', 4);


            g_form.removeOption('state', 9);


    }


   


}


Subhajit1
Giga Guru

Use a On load Client Script to do this:-



if(g_user.hasRole('itil'))


{


g_form.removeOption('state', 'state value');


}


Anurag Tripathi
Mega Patron
Mega Patron

write an onload client script



if(g_user.hasRole('itil'))


{


g_form.removeOption('state','approved')


g_form.removeOption('state','schedules')


//Others


}


-Anurag