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

Multi row variables sorting in descending order

Madhusagar Pal1
Tera Expert

Hi Team,

 

Need help, regarding Multirow variable set.

 

I have scenario, in the Multirow variable set "status date" variable should be sorting in descending order. How can we achieve without scripting. 

MadhusagarPal1_0-1760426886947.png

 

Thanks 

4 REPLIES 4

SD_Chandan
Kilo Sage

Hi @Madhusagar Pal1 ,

we can achieve with catalog client script.

function onLoad() {
var mrvsName = 'your_mrvs_internal_name';
var mrvsData = JSON.parse(g_form.getValue(mrvsName));
if (mrvsData && mrvsData. length > 0) {
mrvsData.sort(function(a, b) {
var dateA = new Date(a.status_date);
var dateB = new Date(b.status_date);
return dateB - dateA;

});
g_form.setValue(mrvsName, JSON.stringify(mrvsData));

}
}



Thank you
Chandan

sanjay02
Tera Guru

Hi @Madhusagar Pal1 ,

If your MRVS pulls from a data from table

you can achieve this like mentioned below :

1.Open the variable configuration inside the MRVS.

2.Add this under Variable Attributes:

order_by_desc=status_date


If my response helped you, please click “Accept as Solution”. Your recognition motivates me to keep sharing knowledge.
Cheers,

Sanjay J.

kaushal_snow
Mega Sage

@Madhusagar Pal1 ,

 

CHECK THIS: https://www.servicenow.com/community/itsm-forum/sorting-a-multi-row-variable-set/m-p/684225

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/

Ankur Bawiskar
Tera Patron
Tera Patron

@Madhusagar Pal1 

when should this run and sort?

On RITM form when variable editor shows MRVS?

OR

As soon as row is added in MRVS during submission?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader