Create custom action button from list view

tpeleg
Tera Expert

Hi,

 

We wish to examine customer requierment on CSM:

 

Add a custom button in each record that will allow them to raise new case from an existing order.

the button just need to redirect for a new case creation page with some parameters from the order record.

tpeleg_0-1742454534517.png

I believe it can be achieved by customizng the list widget (ng-repeate for adding the button in the end of the list): 

tpeleg_1-1742454677079.png

Any suggestions? 

Thanks,

 

Tomer

 

1 ACCEPTED SOLUTION

tpeleg
Tera Expert

@Ankur Bawiskar 

Sure

 

Server:

 

(function() {
	
	var tble =  $sp.getParameter('table')
   var gr = new GlideRecord(tble); // Change table as needed
   gr.addActiveQuery();
   gr.orderByDesc('sys_created_on');
   gr.setLimit(10);
   gr.query();
   var records = [];
   while (gr.next()) {
       records.push({
           sys_id: gr.getValue('sys_id'),
           number: gr.getValue('number'),
           short_description: gr.getValue('short_description'),
				 contact: gr.getDisplayValue('contact')
				 
       });
   }
   data.list = records;
})();

HTML

 

<table class="table table-striped">
<thead>
<tr>
<th>Number</th>
<th>Short Description</th>
  <th>Contact</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="record in data.list">
<td>{{record.number}}</td>
<td>{{record.short_description}}</td>
  <td>{{record.contact}}</td>
<td>
<button class="btn btn-primary" ng-click="performAction(record)">
                   Take Action
</button>
</td>
</tr>
</tbody>
</table>

Client (Add function)

 

	$scope.performAction = function(record) {
       alert('Action triggered for ' + record.sys_id);
       // Example: Trigger a script action or redirect
       window.location.href = 'csm?id=create_order_catalog_item_rp&sys_id=34418320778361105c24f664be5a99f4&order_number='+record.number;
   };

Final result:

 

tpeleg_0-1743070528839.png

 

View solution in original post

5 REPLIES 5

Thanks @tpeleg 

Please mark your own response as correct so that it helps future members.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader