• Ritesh001
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Using JS i am exporting CSV file, How to override the keys with custom column names?

convertArrayOfObjectsToCSV : function(component,objectRecords){
        // declare variables
       var csvStringResult, counter, keys, columnDivider, lineDivider;
       
        // check if "objectRecords" parameter is null, then return from function
        if (objectRecords == null || !objectRecords.length) {
            return null;
         }
        // store ,[comma] in columnDivider variabel for sparate CSV values and 
        // for start next line use '\n' [new line] in lineDivider varaible  
        columnDivider = ',';
        lineDivider =  '\n';
 
        // in the keys valirable store fields API Names as a key 
        // this labels use in CSV file header
        keys = ['case__r.CaseNumber','Name','Resolved__c','In_Conflict__c','On_Another_Case__c','Payment_Terms__c','Original_Charge__c',
                'Proposed_Adjustment_Amount__c','Proposed_Difference_Amount__c','Initial_Proposed_Difference_Amount__c',
                'Adjusted_Total_Charge__c','Difference_Amount__c','Current_Balance__c','Invoice_Bill_Type__c',
                'Invoice_Correction_Type__c','Service_Level__c','Service__c','Rating_Status__c','Rated_Date__c','Pickup_Date__c'];
       csvStringResult = '';
       csvStringResult += keys.join(columnDivider);
       csvStringResult += lineDivider;
 
        for(var i=0; i < objectRecords.length; i++){   
            counter = 0;
           
             for(var sTempkey in keys) {
                 var skey = keys[sTempkey] ;   
              // add , [comma] after every String value,. [except first]
                  if(counter > 0){ 
                      csvStringResult += columnDivider; 
                   }
                 
                 if(skey == 'Case Number') {
                     csvStringResult += '"'+objectRecords[i].Case__r.CaseNumber+'"';
                 }
                 
                 else if(objectRecords[i][skey] != undefined ){
                     csvStringResult += '"'+ objectRecords[i][skey]+'"';
                 }else{
                     csvStringResult += '"'+ '' +'"';
                 } 
               
               counter++;
 
            } // inner for loop close 
             csvStringResult += lineDivider;
          }// outer main for loop close 
       
       // return the CSV formate String 
        return csvStringResult;        
    },
Need Urgent Help in converting the soql result to get as per the below json format as shown in image.


List<Custom_Shipping__mdt> = [selelct Country__c,State__c,Countrycode__c,Sattecode__c from Custom_Shipping__mdt];

example soql result-
Coutry - India , Country code - 34 , State - MH,Delhi State code - 44 ,45
Country Code & Satte Code - 
34-44 , 34-45
This query is giving me all the data from custom metadata
Need to Convert the country & state with their code in below Json format  using wrapper & pass to lightining component.

User-added image
Can someone suggest a trigger using the controller? So user cant create more than 1 contacts per account using apex controller 
Hello there,

I am stuck at the second step in the Billing Specialist superbadge with the following error : 
Challenge Not yet complete... here's what's wrong: 
We couldn't find the Consumption Schedule named 'Panel Maintenance Request'. Please make sure the Consumption Schedule exists, the record contains the correct values according to the requirements and please try again.

I do have created a Consumption Schedule related to Major Solar Panel product :
User-added imagewith the following Consumption Rates :
User-added imageUser-added image
Can someone suggest a trigger using the controller? So user cant create more than 1 contacts per account using apex controller