- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 07:06 AM
Hi,
I have an MRV on my catalog item form and I need to be able to sort them. There are 2 variables in the MRV and below is an example.
Is there a way to sort the mrv by default, based on the Provide Drive Label?
Or am I able to sort this when Flow Designer runs? If so, how can I sort it in Flow?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 06:28 PM
I figured out how to sort an MRV by variable. Here is my script, in case someone could use it.
(function execute(inputs, outputs) {
var mrvs;
var itemID = inputs.record_sysid;
var ritmGR = new GlideRecord('sc_req_item');
if (ritmGR.get(itemID)) {
mrvs = ritmGR.variables[inputs.variable_set_name];
}
var mrvSort = JSON.parse(mrvs);
var sortedArray = mrvSort.sort(function(a, b){
var x = a[inputs.variable_to_sort];
var y = b[inputs.variable_to_sort];
return x < y ? -1 : x > y ? 1 : 0;
});
outputs.sorted_mrv_array = JSON.stringify(sortedArray);
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 06:28 PM
I figured out how to sort an MRV by variable. Here is my script, in case someone could use it.
(function execute(inputs, outputs) {
var mrvs;
var itemID = inputs.record_sysid;
var ritmGR = new GlideRecord('sc_req_item');
if (ritmGR.get(itemID)) {
mrvs = ritmGR.variables[inputs.variable_set_name];
}
var mrvSort = JSON.parse(mrvs);
var sortedArray = mrvSort.sort(function(a, b){
var x = a[inputs.variable_to_sort];
var y = b[inputs.variable_to_sort];
return x < y ? -1 : x > y ? 1 : 0;
});
outputs.sorted_mrv_array = JSON.stringify(sortedArray);
})(inputs, outputs);