The CreatorCon Call for Content is officially open! Get started here.

How to OrderBy Sequence

Kusuma2
Kilo Guru

Hi All,

How can we show the records based upon the sequence of choice list field.

I have a choice list field on Outage table and based upon the sequence of the choices I need to show outage records.

Inshort I need to OrderBy the sequence of Choices.

How can I acheive it?

2 REPLIES 2

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

read this topic discussion thread, it will help you to do it:

https://community.servicenow.com/community?id=community_question&sys_id=ef6c47a5db9cdbc01dcaf3231f96...

Hope this will be useful for you.

Please, remember to mark Correct or Helpful if you find my response useful.

Cheers
Alberto

Thank you I need to make changes on the server side script of the widget above link is related to client script.

Any Ideas How to order by Sequence rightnow  I am using the below script to get the sequence of the choices but my only problem is to show Outage table records based upon this sequence.

var seq = new GlideRecord('sys_choice');
seq.addEncodedQuery('nameLIKEoutage^elementLIKEtype');
seq.orderBy('sequence');
seq.query();


while(seq.next()){


gs.print( 'Element:'+seq.value+' :: Sequence'+seq.sequence);


}