Return values from script include

servicenow14710
Tera Expert

In a catalog item there is a field lets say ids where the ids of the user i selct form sys_user table will be populated.

 

The field names where i enter users lets suppose entered as a,b, c, d . and the output (ids)i get from these will be like a,c,d,b . The order is messing . Can someone help with this i am using script include.

         

       
        while (record.next()) {
            for (var i = 0; i < fields_len; i++) {
                arr.push(record.getValue([i]));
            }
        }
        return arr.join(" , ");
    },

6 REPLIES 6

@Anurag Tripathi : Thanks for the reply. So i cannot change the sequence but only append its key to value in the response. 

But the response field needs to bepopulated only with value. 

When you return the value in this format -> usr3#id3,usr4#id4,usr2#id2,usr1#id1

Or Json

Then your client script you can extract this and know which id is for which username and populate accordingly, there is not dependency on sequence then.

-Anurag