The CreatorCon Call for Content is officially open! Get started here.

Hide button on service portal based on condition in server script

Bruler1230
Tera Expert

Hello,

I need to hide a button on the service portal if a condition in the server script is true. From what i can tell, the button should disappear, as the condition is returning the correct value. Do i need to pass something to the client script to make it disappear? Or is a condition in the server script enough to make this happen?

data.hideButton = true;
if (<condition>)
data.hideButton = false;

and the ng-if for the button in the HTML is using data.hideButton

Do i need anything else for this to work? in the client script possibly? Let me know if more info is needed. 

Thanks.

3 REPLIES 3

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

your steps seems correct:

https://community.servicenow.com/community?id=community_question&sys_id=60efc5dadb42ab409a64e15b8a96...

Please check your condition first, if still doesn't work, please share code + printscreens with example.

Cheers

Alberto

Pratiksha Kalam
Kilo Sage

Hello,

Check this for help,

Show/hide button

If answer is helpful please mark correct and helpful!


Thanks,
Pratiksha

Anil Lande
Kilo Patron

Hi,

Yes, you are using correct logic, but I guess you are not checking correct condition.

if in your server script 

data.hideButton = false;

then

<button  type="button" ng-if="! data.hideButton">Submit</button>

 

will hide the button

 

Thanks,

Anil

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande