public class ServiceContractController {
@AuraEnabled(cacheable=true)
public static List<SVMXC__Service_Contract__c> getSortedContracts(Id opportunityId, String sortField, Boolean isAscending) {
// Query related Service/Maintenance Contracts with Opportunity relationship
String sortOrder = isAscending ? 'ASC' : 'DESC';
// Query based on Opportunity lookup field (assuming it exists on the Service/Maintenance Contract object)
return [SELECT Id, Name, SVMXC__Start_Date__c, SVMXC__End_Date__c FROM SVMXC__Service_Contract__c WHERE Related_Opportunity_SVMX_PS__c = :opportunityId ORDER BY :sortField :isAscending];
}
}
cHVibGljIGNsYXNzIFNlcnZpY2VDb250cmFjdENvbnRyb2xsZXIgewoJQEF1cmFFbmFibGVkKGNhY2hlYWJsZT10cnVlKQogICAgcHVibGljIHN0YXRpYyBMaXN0PFNWTVhDX19TZXJ2aWNlX0NvbnRyYWN0X19jPiBnZXRTb3J0ZWRDb250cmFjdHMoSWQgb3Bwb3J0dW5pdHlJZCwgU3RyaW5nIHNvcnRGaWVsZCwgQm9vbGVhbiBpc0FzY2VuZGluZykgewogICAgICAgIC8vIFF1ZXJ5IHJlbGF0ZWQgU2VydmljZS9NYWludGVuYW5jZSBDb250cmFjdHMgd2l0aCBPcHBvcnR1bml0eSByZWxhdGlvbnNoaXAKICAgICAgICBTdHJpbmcgc29ydE9yZGVyID0gaXNBc2NlbmRpbmcgPyAnQVNDJyA6ICdERVNDJzsKICAgICAgICAKICAgICAgICAvLyBRdWVyeSBiYXNlZCBvbiBPcHBvcnR1bml0eSBsb29rdXAgZmllbGQgKGFzc3VtaW5nIGl0IGV4aXN0cyBvbiB0aGUgU2VydmljZS9NYWludGVuYW5jZSBDb250cmFjdCBvYmplY3QpCiAgICAgICAgcmV0dXJuIFtTRUxFQ1QgSWQsIE5hbWUsIFNWTVhDX19TdGFydF9EYXRlX19jLCBTVk1YQ19fRW5kX0RhdGVfX2MgRlJPTSBTVk1YQ19fU2VydmljZV9Db250cmFjdF9fYyBXSEVSRSBSZWxhdGVkX09wcG9ydHVuaXR5X1NWTVhfUFNfX2MgPSA6b3Bwb3J0dW5pdHlJZCBPUkRFUiBCWSA6c29ydEZpZWxkIDppc0FzY2VuZGluZ107CiAgICB9Cn0=