button visibility in the servicenow portal

chandanpatra
Tera Contributor

Hi All,

 

I am receiving the current sys_id of the location example america location and i have created three buttons in the HTML code 

Server side code :var queueId = $sp.getParameter('location_id');

HTML code : 

<div id="buttonContainer">
<button ng-click="home()" ng-if="data.showButton" class="spacedButton" ng-class="{'clicked-button': buttonClicked}" >Office Mgmt</button>
<button ng-click="home1()" ng-if="data.showButton" class="spacedButton" ng-class="{'click-button': buttonClick}">Tech Majilis</button>
<button ng-click="home2()" ng-if="data.showButton" class="spacedButton" ng-class="{'clcked-button': buttonClcked}" >People Exp</button>
</div >

 

If the location is america than Office Mgmt,Tech Majilis buttons should visible , if the location is Dubai than Tech Majilis and people EXP buttons are visible else Office Mgmt,People Exp should visible .

 

 

Can you provide me the code based on the location . I am not able get the code 

 

Thanks and Regards,

Chandan

1 ACCEPTED SOLUTION

Suraj Sharma
Giga Guru

See for two condtion You have make two condtions So you will not able to achieve your condition by just adding ng-if="data.showButton"  This only

View solution in original post

4 REPLIES 4

chandanpatra
Tera Contributor

@Sid_Takali  Can you help me 

Suraj Sharma
Giga Guru

When you are loading you are getting sys id of the Location ..
 in server side GlideRecord the location and get the name in a variable .
var locGr=new GlideRecord('cmn_loaction');
if(locGr.get(queueId)){

data.locName=locGr.name;

}

In html 

<button ng-click="home()" ng-if="data.locName==america || !(data.locName==dubai)" class="spacedButton" ng-class="{'clicked-button': buttonClicked}" >Office Mgmt</button>
<button ng-click="home1()" ng-if="data.locName==america || !(data.locName==dubai)" class="spacedButton" ng-class="{'click-button': buttonClick}">Tech Majilis</button>
<button ng-click="home2()" ng-if="data.locName==dubai" class="spacedButton" ng-class="{'clcked-button': buttonClcked}" >People Exp</button>
</div >

If this Code solve your query then mark helpfull this article.

Thanks and regards 
Suraj sharma

Thank you for giving answer but i want to include this statement also in all the buttons :

ng-if="data.showButton" 

 

@Suraj Sharma 

Please help me to include this statement

Suraj Sharma
Giga Guru

See for two condtion You have make two condtions So you will not able to achieve your condition by just adding ng-if="data.showButton"  This only