[HELP] Header Menu Creation from Scratch for Community Portal

Community Alums
Not applicable

Hi,

 

I'm new to Service Portal, actually to the Service Now world, and I'm tasked with redoing a portal. It seems I won't be able to reuse most of the widgets, including the Menu.

I'm creating a menu from scratch and I want to dynamically obtain the Menu Items.

 

Erro

ThalesSantos_0-1710029025672.png

 

Server Script

 

(function () {

	data.fields = options.fields || 'label, sys_id';
	data.items = getMenuItems();

	function getMenuItems() {
		var items = [];
		var searchMenus = new GlideRecord('sp_rectangle_menu_item');
		searchMenus.addEncodedQuery("sp_rectangle_menu=1d8e6f891b6cce502d0e87bfe54bcbbf");
		searchMenus.orderBy('order');
		searchMenus.setLimit(5);
		searchMenus.query();
		while (searchMenus.next()) {
			var obj = {};
			$sp.getRecordElements(obj, searchMenus, data.fields);
			items.push(obj);
			

		}
		
		return items;

	}

})();

 

 

HTML Template

 

<div class="buttons-container">
  <button class="custom-button" ng-repeat="item in data.items">
      <div class="button-icon">
      </div>
    <span>
    <a href="?id=community_forum&sys_id={{item.sys_id.value}}">
      {{item.label.display_value}}
     </a>
    </span>
  </button>
</div>

 

 

NOTE: I have to study while I execute, so I don't know the best practices yet, including Angular is new to me.

 

Can you help me? Is there a simpler way to do this?

 

 

0 REPLIES 0