简体   繁体   中英

What is the meaning of this code in service now?

I am usin My requests widget in Server Now. There is this line of code.

    var notClosedResolved = 'stateNOT IN6,7';
    var closedResolved = 'stateIN6,7';

What that means?

Plase help Thanks in advance

It's an encoded query. State 6/7 by default are the numeric values of the states stored within ServiceNow.

So 'Resolved' and 'Closed' are the "Display" values (what the end user sees) and 6/7 are the numeric value behind those display values, to allow for easier accessibility when developing.

Effectively, the notClosedResolved/closedResolved indicate that they'll be used when doing some form of query.

For example:

//The two variables storing the encoded queries.

var notClosedResolved = 'stateNOT IN6,7';;
var closedResolved = 'stateIN6, 7';

//The query being added to the GlideRecord, then queried.
var gr = new GlideRecord('incident');
gr.addEncodedQuery(notClosedResolved);
gr.query();

//If any tickets matching the query (Not closed or resolved) exist, then do whatever is in the while and update the record
while(gr.next()){
    gr.short_description = 'Example - All non-closed/resolved incidents';
    gr.update();
}

//The query being added to the GlideRecord, then queried.
var gr = new GlideRecord('incident');
gr.addEncodedQuery(closedResolved);
gr.query();

//If any tickets matching the query (Closed or resolved) exist, then do whatever is in the while and update the record
while(gr.next()){
    gr.short_description = 'Example - All closed/resolved incidents';
    gr.update();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM