Skip to main content

Posts

Showing posts from December, 2020

Service Portal: pass a url parameter to a widget on a page

example HTML: <div> <a href = "{{data.profile_url}}" class = "h4 text-primary m-b-sm block" > <span class = "ng-binding" > Edit Profile </span> &nbsp; <i class = "fa fa-edit" ></i> </a> </div> [ var sURL = '<portal>?id=<portal_page>&sys_id=' + data . sysUserID + '& sysparm_aparameter =true' ; data . profile_url = sURL ; ] example server script to catch the parameter:  //var sURL_editparam = gs.action.getGlideURI().getMap().get(' sysparm_aparameter ');//--would work, but below is neater var sURL_editparam = $sp . getParameter ( " sysparm_aparameter " ); if ( sURL_editparam == 'true' ) { gs . addInfoMessage ( 'parameter passed ); }

For loops in javascript

 ref: For loops   var prop1 = gs . getProperty ( "a-property" ); //--, delimited sys_ids (or single sys_id) var prop2 = gs . getProperty ( "a-property2" ); //--, delimited var prop1_arr = prop1 . split ( ',' ); var prop2_arr = prop2 . split ( ',' ); for ( SYSID in prop1_arr ){ gs . print ( prop1_arr [ SYSID ]); } for ( SYSID2 in prop2_arr ){ gs . print ( prop2_arr [ SYSID2 ]); }

Service Portal: A widget with tabs instead of side menu, for SC Categories

[ code is not yet quite working for the sub-arrays, look at widget "SC Categories" and try to incorporate for the sub category lookups ] HTML : <div class = "banner-blue" > <ul class = "nav nav-tabs" > <li class = "dropdown" ng-repeat = "parentcategory in ::data.parentCats" > <a class = "dropdown-toggle" data-toggle = "dropdown" href = "javascript:void(0)" > {{parentcategory.title}} <span class = "caret" ></span> <ul class = "dropdown-menu" > <li ng-repeat = "childitem in c.childItems" color = "black" ><a color = "black" href = "javascript:void(0)" > {{childitem.child_title}} </a></li> </ul> </a> </li> </ul> </div> CSS : div.banner-blue{ background-co...

Get unique parent categories (service catalog categories) - GlideAggregate - and grab their subcategories

var ga = new GlideAggregate ( 'sc_category' ); ga . addAggregate ( 'COUNT' , 'parent' ); ga . addQuery ( 'sc_catalog' , '9f6ef0cddb028f80edfc7cbdae96191c' ); ga . addNotNullQuery ( 'parent' ); ga . addHaving ( 'COUNT' , '>' , 0 ); ga . query (); var dupls =[]; var parentCats =[]; dupls . push ( "The following " + ga . getRowCount () + " records are duplicate on parent" ); while ( ga . next ()) { var DuplLine = ga . getAggregate ( 'COUNT' , 'parent' ) + " => " + ga . getElement ( 'parent.title' ); dupls . push ( DuplLine ); //gs.print(DuplLine); parentCats . push ( ga . getElement ( 'parent.title' ) ); } var output = parentCats . toString (); output = output . replaceAll ( "," , "\n" ); gs . print ( output ); output :  *** Script: Hardware Software Devices Accessories Stora...