expert advice needed

chercm
Mega Sage

we have a project to add a new barcode scanning widget on servicenow but the admin wants have a container to host that widget on the walkup check in page without affecting the current functionality. he is does not want to clone that existing page with an acl control on it

 

solution  :using the widget directive in your container's HTML 

 

is this correct way of doing ?

2 REPLIES 2

Community Alums
Not applicable

Hi @chercm ,

Your Solution approach is in the right direction !!

If there is no specific reason to use the plain widget directive instead of spWidget you could do something like:

HTML

<div class="panel">
  <div ng-repeat="elem in c.data.elements">
  	<sp-widget widget="elem"></sp-widget>
  </div>
</div>

 

Server Script

var listOptions = [
     {
		"table":"sc_request",
		"display_field":"request",
		"filter":"request_state=requested^opened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe",
		"order_direction": "",
		"order_by": "sys_created_on",
		"sp_page":"nr_sc_request",
		"secondary_fields":"request_state,price",
		"maximum_entries": 2
     },
     {
		"table":"incident",
		"display_field":"number",
		"filter":"state=1^opened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe",
		"order_direction": "desc",
		"order_by": "sys_created_on",
		"sp_page":"nr_sc_request",
		"secondary_fields":"state,short_description",
		"maximum_entries": 3
    }]
	
data.elements = listOptions.map(function(optionList){
	return $sp.getWidget('widget-simple-list', optionList);
});

 

Results:

 

And the same thing should be able to be done (small tweak) with spUtil if it's required to be done client side.

 

chercm
Mega Sage

i have this laptop scanning service portal widget : 

 

chercm_0-1714654049671.png

 

 

 

how can i embed this in a container on the walkup portal page without cloning ? 

 

chercm_1-1714654049676.png