How to change the sort order of a Lookup Select Box Variable type?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 08:02 PM
I have created a variable of Lookup Select Box type in which look up value field(Available Shift)is a choice type field . I have used below variable attribute but it is not showing in the correct sequence as defined in the choice field:
Variable attribute:
ref_auto_completer=AJAXTableCompleter,ref_ac_columns=office_location;date;shift_type,ref_ac_columns_search=true,ref_ac_order_by=sequence
Can someone please help how to show the timings in the dropdown sequence wise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 10:48 PM
Okay, Thanks for the help. I am stuck in one issue can you please help what I am missing
There are 2 tables let's say one is A table which have employee and training completion check box fields
other is B table in which ticket is created when employee submit the request
My requirement was to show training completion check box field which was on A table to B table and value will be updated on the basis of A. The value of the field should not be updated through table B. The table B should only reflect the value of table A .
I created script include and business rule which is working correctly in the scenario when record of the employee is already present in table B and ticket for the employee is created in table A post that.. When I update the field value in table B it reflect the same in table A.
It is not working in the scenario when record of the employee is not present in table B and ticket for the employee is created in table A and post that when I created a record in table B for the same employee and when I update the field in table B it doesn't update the value in table A. It is setting null.
The value in the table A should always be updated based on table B irrespective of record in table B is created before or after the table A.
Script Include:
var ORTUtils = Class.create();
ORTUtils.prototype = {
initialize: function() {},
//Given a sys_id of a user record, will return sys_id of the user's Training Info record, or "" if not found
getInfoFromID: function(userId) {
if (!userId) {
return "";
} //sanity check
var user = new GlideRecord("x_expe2_ort_training_info");
if (user.get("employee", userId)) {
return user.getUniqueValue();
} else {
return "";
}
},
type: 'ORTUtils'
};
Business Rule: before insert update
(function executeRule(current, previous /*null when async*/ ) {
//Set Training info reference
var trainingInfo = new x_expe2_ort.ORTUtils().getInfoFromID(current.employee); //sys_id or "" returned.
if (trainingInfo) {
current.training_info = trainingInfo; //Sys_id is return.
} else {
current.training_info = ""; //Sys_id is return.
}
})(current, previous);
I have created the field 'Training info' on table B which is reference to Table A and by using dot walking I show the Training Completion field on table B
Table A:
Table B :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2021 08:17 AM
Any solutions for this ? please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 02:48 AM
This is the existing know issue from ServiceNow side & it can't be fixed in the future release as well.
See the KB0695435 & PRB1256488.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=
Please mark this as correct if it answer your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
This is the only correct answer - if the reference qualifier starts with javascript, then, there is no way to order by sequence.
The fastest and the easiest way is to create a Catalog Client Script and utilize g_form.addOption(String fieldName, String choiceValue, String choiceLabel, Number choiceIndex) when Number choiceIndex is the sequence than to use reference qualifier.
Thank you for providing this article, you saved me time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 11:42 PM
Maybe it is too late but you can also use this for example in reference qualifier:
question.question_text=your_question^ORDERBYorder
