State selection availability based on assignment group

zacks
Tera Contributor

State Selection, assignment group and notification

I added an additional state "More Information" to my Change Task. I want this state to be visible to specific assignment group members, i.e if the user is not a member an assignment group, that state should not be available on the change task. If the "More Information" state is selected and updated, it should send a notification to the specific people. I think I can do this in a workflow. I have tried to use some Client Script to control the availability of the state to no avail. Please can anyone help me?

Thank you

5 REPLIES 5

Raju Koyagura
Tera Guru

To hide "More information" choice value to other users you should depend on client script.


get the current logged in user, create glide record for group member table and apply addquery condition with logged in user sysid. In if condition use method to disable choice value.



To send email notification, yea you should use workflows are in BR also you can call eventQueue method to trigger your notifications.



tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Zack,



You could perhaps use a UI Policy to determine visibility of "More Information" state on a form.


If you should do I am not sure.


Dynamic filters might be useful also (or instead).


Using Filters and Breadcrumbs - ServiceNow Wiki



Evidently you can create notifications based on conditions referring to arbitrary conditions.


One aspect is maintainability, what needs to be changed when the requirements change or more requirements become apparent.


I have an idea avoiding workflows is good in this context.



Best Regards



Tony


sumeet_n
Kilo Guru

Hi Zack,



For state manipulation, you would need a onload client script and a script include. Write a function in script include which would return true / false based on the logged in user's validation across group membership (assuming you know how to validate). Make an ajax call to this function via onload client script on the form. Depending on the value returned (true/false) execute "removeOption" on the choice list field to remove "More information" whenever needed.



@ ways for notification:


1. You can definitely do it via workflow.


2. If not, you can write after update BR to trigger an event for the same notification. This BR would only run when the "state changes to 'More Information'".



GlideAjax - ServiceNow Wiki


Jamsta1912
Tera Guru

Hello Zack,



Do you want to limit the 'More Information' choice to one specific, named assignment group, or to the assignment group the change task is assigned to (ie dynamically)? If the former, you could achieve this by adding a new role to that particular group, eg 'my_role' and then using an onLoad client script to remove the 'More Information' option for everyone who does not have that role:



function onLoad() {


  if (!g_user.hasRole('my_role')){


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


  }


}



For the email notification, you could use a condition on 'When to Send', like this:



find_real_file.png


I hope this is helpful.


Jamie.