Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to make buttons dynamically

chandan86patra
Tera Contributor

Hi All,

 

I have requirement that for example 

case 1 if the location in india i am receiving the 3 Values like A , B , C 

Case if the location is  America than we are receiving the 2 values like A and B.

For the above server script written in portal

var queue= new GlideRecord('wu_location_kiosk');
      queue.addQuery('location_queue',queueId);
      queue.query();
  var ab=[];
  while(queue.next())
    {
    ab.push(queue.name.toString());

}

 from the ab value in array

 

based on the location values i need to create dynamically buttons

 

by using this script :

<span ng-repeat="buttonname in buttonarray" ><button ng-click="'{{buttonname}}'" {{buttonname}}</button></span>

 

Can you help me  to build the HTML code to create buttons based on the values 

Thanks,

Chandan

1 ACCEPTED SOLUTION

Prana Krushna
Giga Guru

html
<div>
<button ng-repeat="buttonname in data.buttonarray" ng-click="function call">{{buttonname}}</button>
<div>

Server script
data.buttonarray=[];

var queue= new GlideRecord('wu_location_kiosk');
queue.addQuery('location_queue',queueId);
queue.query();
while(queue.next())
    {
    data.buttonarray.push("<buttonname>");

}

 

Let me know if you need more help

 

Mark this helpful if it works for you

View solution in original post

1 REPLY 1

Prana Krushna
Giga Guru

html
<div>
<button ng-repeat="buttonname in data.buttonarray" ng-click="function call">{{buttonname}}</button>
<div>

Server script
data.buttonarray=[];

var queue= new GlideRecord('wu_location_kiosk');
queue.addQuery('location_queue',queueId);
queue.query();
while(queue.next())
    {
    data.buttonarray.push("<buttonname>");

}

 

Let me know if you need more help

 

Mark this helpful if it works for you