How to hide a value in a list fields using Business Rule

ursnani
Giga Guru

Can anyone please suggest me how to hide a value using business rule.

To be specific When ever the state is other draft and after inserting the problem the draft value in the state field should not be visible.

can anyone please help me on this .

Thanks

1 ACCEPTED SOLUTION

amlanpal
Kilo Sage

Hi Naveen,



For this you need to write an onLoad Client Script. I have checked in my instance against another state and it is working fine. Request you to check the below script and let me know. Find the below screenshot.


If your requirement is to hide the State 'Draft' for any specific view you can mentioned in the 'View' under which the Client Script will run.


find_real_file.png



I hope this helps.Please mark correct/helpful based on impact


View solution in original post

8 REPLIES 8

amaradiswamy
Kilo Sage

Hi Naveen,



Could you please elaborate your requirement, do you want to hide a choice value in state field?



Thanks and regards


Swamy


ursnani
Giga Guru

yes eactly,



I have 5 value initially when creating a problem


draft,open,pending,closed/resolved.



once we submit the problem with state as open or pending, then the 'draft' value should not be seen .


Hi Naveen,



This can't be done using Business Rules, you have to use client script (using g_form method) which will work only one forms.



http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#removeOption



Thanks and regards


Swamy


ursnani
Giga Guru

I have written the following businesr rule



Onafter Business Rule   { Insert}



(function executeRule(current, previous /*null when async*/) {



      var ga = new GlideRecord('problem');


      var pb = ga.addQuery('state',1);


      pb.addOrCondition('state',2);


      pb.addOrCondition('state',3);


      pb.addOrCondition('state',4);


      ga.query();


      while(ga.next()){              


      }


})(current, previous);



i dont know what to write in the code to hide the field. can anyone please suggest.