Reference glide_list in Script (for loop not validating XML)

ctrusty
Kilo Contributor

Scope: Filter on-call calendar drop down by using a glide_list (array) of values. This could be used in multiple variations on what the glide_list would actually reference. For me, it is a new field on the company table referencing other companies. We want a user from Company A to be able to see ROTA groups that belong to Company A, B, C.

Schedules Pages -> Group Rosters. HTML section.


<!-- get the groups that have a roster defined -->
           <g:evaluate>
                 var groupIds = [];
                 var rotaGR = new GlideRecord('cmn_rota');
                 rotaGR.addActiveQuery();
                 rotaGR.query();
                 while (rotaGR.next()) {
                       groupIds.push(rotaGR.group + '');
                 }
                 // Find current user's company sys_id
                 var rotaBU = new GlideRecord('core_company');
                 rotaBU.addQuery('sys_id', gs.getUser().getCompanyID());
                 rotaBU.query();
               
                 // Reference glide list 'u_area' using for loop
                 var list = rotaBU.u_area.toString();
                 var array = list.split(",");

               // if we have groups, query for groups with rotas
             // and all values in the u_area glide list on current user's company record
                 if (groupIds.length > 0) {
                       rotaGR = null;
                       var groupGR = new GlideRecord('sys_user_group');
                       groupGR.addQuery('sys_id', groupIds);
                       var grOR = groupGR.addQuery('u_business_unit', gs.getUser().getCompanyID()); 
                 for (var i=0; i < array.length; i++) {
                       grOR.addORCondition('u_business_unit', array<i>);
                 }
                       groupGR.orderBy('name');
                       groupGR.query();
                 }
           </g:evaluate>


The XML keeps throwing the following error on save:
Error at line (25) The content of elements must consist of well-formed character data or markup.

It does not like the for loop at all. As soon as I remove that for loop it saves without issue. Any thoughts? Is it possible I can't use a for loop here?
2 REPLIES 2

Mark Stanger
Giga Sage

It's probably the


'<'
symbol that it doesn't like. That's a reserved character that must be escaped. You can replace it with

'<'
. See here for details.
http://wiki.service-now.com/index.php?title=How_to_Escape_in_Jelly



mark.stanger


Though I'm not getting my desired results, that page helped and it is passing the XML now. I used the HTML alternative for the

<
which is

<


That still may not be correct but it keeps it from getting an error.

'<'
didn't work either.

Thanks Mark!