• zubair ahmed 20
  • NEWBIE
  • -1 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hello Friends , 

I am getting the below issue in Vscode after new version update . 

"The JAVA_HOME environment variable points to a missing folder. For information on how to setup the Salesforce Apex extension, see Set Your Java Version."

I have my java version in below path :
User-added image

i have installed again ,  vscode cli , extention pack . 

can you please tell the highlighted one is corect ?
User-added image
do i need to put anything in workspace as well ???

please help me .... if any one wanted i can screen share you in gmail , my id is salesforceseekar@gmail.com .... please feel free to ping as i wanted to resolve this issue .

 
Lightning component
<aura:component controller="SfObjectController" >
 <aura:attribute name="records" type="object"/>
 <aura:attribute name="fieldname" type="String[]"/>
    <aura:attribute name="index" type="Integer[]"/>
<aura:attribute name="allobjects" type="String[]"/>
<aura:attribute name="allfields" type="String[]"/>
<aura:attribute name="allresults" type="String[]"/>
<aura:attribute name="query" type="String"/>
<aura:attribute name="temp" type="Integer" default="0"/>
 <aura:handler name="init"  action="{!c.doInit}" value="{!this}"/>
    
        <lightning:select aura:id="select" label="Select Object" onchange="{!c.onChangeobject}"  required="true">
            <option value="">-- None --</option>
              <aura:iteration items="{!v.allobjects}" var="obj">
              <option value="{!obj}">{!obj}</option>
              </aura:iteration>
       </lightning:select>
    

    
     <ui:inputSelect aura:id="selectfield" class="slds-select"  multiple="true" label="Select Fields" required="true" change="{!c.onChangefield}" >
           <aura:iteration items="{!v.allfields}" var="field">
                 <option value="{!field}" text="{!field}"></option>
            </aura:iteration>           
 </ui:inputSelect>
    
      Your Query is: <ui:outputText value="{!v.query}"/>    
   <button type="button" onclick="{!c.showallrecords}">Execute</button> 
   <!--for multi-select picklist [select2]  
   <div class="slds-form-element">  
     <label for="picklist">Fields</label> <br/>
     <select aura:id="selectfield" style="width:100%" onchange="{!c.onChangefield}" class="select2Class" multiple="multiple">
       <aura:iteration items="{!v.allfields}" var="field">
           <option value="{!field}"> {!field} </option>
       </aura:iteration>     
     </select>  
      
    </div>-->  

    
      <table>        
      <thead>
      <tr >
       <aura:iteration items="{!v.fieldname}" var="field">
      <th>
      {!field}
            
       </th>
      </aura:iteration> 
          
                       
        </tr> 
       </thead>
           <aura:iteration items="{!v.allresults}" var="val">      
           
         <tr>
             
        
             
    <!--     <aura:iteration items="{!v.index}" var="ind">
      
              <td>
                {!val} 
        
            </td>
            
       
      </aura:iteration> -->
             
             
             
             
             
             
             
             
             
             
             
              

            
             <!--

                for(int i =0;i<field.length;i++){
                     <td>
                        {!val[i]} 
        
                    </td>
                
                }


             -->
             
             
            
             
         <td>
        {!val[0]} 
        
        </td>
              
        <td>
        {!val[1]} 
        
        </td>
        <td>
        {!val[2]} 
        
        </td>
        <td>
        {!val[3]} 
        
        </td>
                
             
       </tr> 
     
      </aura:iteration>
          
    </table>
      
      

  
            


  
    
</aura:component>

JS File
({
    doInit : function(component, event, helper) {
        console.log("inside init: ");
        // Create the action
        var action = component.get("c.getObjectName");
        console.log("inside init:"+action);
        // Add callback behavior for when response is received
        action.setCallback(this, function(response) {
            var state = response.getState();
            console.log(response.getReturnValue());
            console.log(response.getReturnValue());
            if (state == "SUCCESS") {
                component.set("v.allobjects", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        // Send action off to be executed
        $A.enqueueAction(action);    
    },
    onChangeobject: function(component, event, helper) {
        //Do something with the change handler
        console.log("inside on changeobject");
        var selectedvalue=component.find("select").get("v.value");
        console.log("inside onchangeobject:"+selectedvalue);   
        //debugger;
        var action = component.get("c.getFieldName");
        action.setParams({ "selectedObject" : selectedvalue });
        
        //console.log(" onchangeIn:"+ selinst);
        action.setCallback(this, function(response) {
            var state = response.getState();
            console.log(response.getReturnValue());
            if (state == "SUCCESS") {
                component.set("v.allfields", response.getReturnValue());
                console.log("inside if state success");
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        $A.enqueueAction(action);
        
    },
    
    onChangefield : function(component, event, helper) {
        //Do something with the change handler
        console.log("inside on changefield");
        var selectedvaluefield=component.find("selectfield").get("v.value");
        var selectedvalue=component.find("select").get("v.value");
        var fieldname= [];
        fieldname=selectedvaluefield.split(';');
        console.log("fieldname after conv:"+fieldname);
        component.set("v.fieldname", fieldname);
        
        
        
        
        // var selectedValueoffield=component.find("selectfield").get("v.value");
        console.log("inside onchangefield:"+selectedvaluefield);   
        console.log("inside onchangefield:"+selectedvalue);  
        var action = component.get("c.getQuery");
        action.setParams({
            selectedField:selectedvaluefield,
            selectedObj: selectedvalue
        }); 
        // action.setParams({ "selectedField" : selectedvaluefield });
        // action.setParams({ "selectedObj" : selectedvalue });
        //console.log(" onchangeIn:"+ selinst);
        action.setCallback(this, function(response) {
            var state = response.getState();
            console.log(response.getReturnValue());
            if (state == "SUCCESS") {
                component.set("v.query", response.getReturnValue());
                
                
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        $A.enqueueAction(action);
        
    },
    
    showallrecords: function(component, event, helper) {
        console.log("showallrecords");
        //Do something with the change handler
        console.log("showallrecords");
        
        var selectedvaluefield = component.find("selectfield").get("v.value");
        var selectedvalueofquery = component.get("v.query");
        var fieldname = [];
        fieldname = selectedvaluefield.split(';');
        console.log("fieldname after conv:"+fieldname);
        component.set("v.fieldname", fieldname);
        
        var action = component.get("c.getQueryResults");
        action.setParams({ "selectedQuery" : selectedvalueofquery });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state == "SUCCESS") {
                var obj=response.getReturnValue();
                obj = JSON.parse(obj);
                var temp;
                var completeRecord=[];
                
                for(temp = 0; temp < obj.length; temp++){
                    console.log(obj);
                    var record=obj[temp]  ; 
                    console.log(record)
                    console.log(fieldname.length)                    
                    var i;
                    for(i=0;i<fieldname.length;i++){
                        var field = fieldname[i];
                        console.log(field);
                        
                        var recordtemp=JSON.stringify(record);
                        recordtemp=recordtemp.toLowerCase();
                        record=JSON.parse(recordtemp);
                        
                        var tem=[];
                        tem.push(record)
                        
                        
                         var recordValue = record[field];
                        console.log(recordValue);
                        //  console.log(Object.values(recordValue))
                         if(recordValue==undefined)
                             recordValue="";
                         
                         completeRecord.push(recordValue);
                     /*   if(i==fieldname.length-1){
                             completeRecord.push("</br>");  
                        }*/
                         
                     }
                     
                     
                     
                 }
                 // obj=obj.split(":").join('');
                 // obj=obj.split("\"\"").join("-");
                 
                 //  typeof obj;
                 //   obj=obj.filter(Boolean);
                 
                  console.log(completeRecord);
                 /**  var fil=obj.filter(function(el){ return el!==''; });      
                                 
                      console.log("fil:"+fil);**/
                
                // obj=JSON.parse(obj);
                var p;
                var q;
                var tem=[];
                var tem2=[];
               for(q=0;q<(completeRecord.length)/fieldname.length;q++){
                for(p=0;p<fieldname.length;p++){
                    
                    
                    tem.push(completeRecord[(q*fieldname.length)+p]);
                   // console.log( tem);
                                        
                    //tem = JSON.parse(tem);
                }
                  // tem=JSON.stringify(tem);
                   tem2.push(tem);
                  // console.log("INSIDE TEM");
     
                 //  console.log(tem);
                   
                  // console.log("tem2 INSIDE");
                   
                   tem=[];
                   // component.set("v.allresults", tem);
                }
                console.log("OUTSIDE TEM2");
               // tem2=JSON.stringmasterrecordidify(tem2);
                 
                console.log( tem2);
                component.set("v.allresults", tem2);
                
                
                var index=[];
                for(p=0;p<fieldname.length;p++){
                    index.push(p);
                    }
                
                
                
                component.set("v.index", index)
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
         $A.enqueueAction(action);
         
     } 
})
Apex
public  with sharing  class SfObjectController {
  @AuraEnabled
  public static String selectedObj {get;set;}  
  @AuraEnabled
    public static List<String> getObjectName(){
        List<String> objects=new List<String>();
        List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();  
        for(SObjectType sot:gd){
           // system.debug('element:'+sot);
           objects.add(sot.getDescribe().getName());
           objects.sort();  
        }
         for(String ele:objects){
             //String obj=ele;
             system.debug('element:'+ele);
          // objects.add(sot.getDescribe().getName());
          // objects.sort();  
        }
        return objects;
    }
    
  @AuraEnabled  
 public static  List<String> getFieldName(String selectedObject)
    {    system.debug('selectedObject:'+selectedObject);
         SfObjectController.selectedObj=selectedObject;
         system.debug('selectedObj:'+selectedObj);
          Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(selectedObj).getDescribe().fields.getMap();

        List<String> strList = new List<String>(objectFields.keySet());
        return strList;
       
    }
 @AuraEnabled  
     public static String getQuery(String selectedField , String selectedObj)
    {   system.debug('selectedField:'+selectedField);
        system.debug('selectedObj:'+selectedObj);
        String strforquery='SELECT '+selectedField+' FROM '+selectedObj;
        strforquery = strforquery.replace( ';' , ',' );

        return strforquery;
       
    }
    @AuraEnabled  
    public static String getQueryResults( String selectedQuery) {
        System.debug('strQry'+selectedQuery);
        List<sObject> strResults = Database.query(selectedQuery);
        
        return JSON.serialize(strResults);
    }
}data is not showing up properly under each column

 
Hi all,

We need to implement the following pattern at my org:
  • callout to external data source
  • if that callout takes too long (according to some configurable threshold), log an error (ie do some DML)
  • if that callout timed out on the remote server, try it again
Recognizing the potential for the dreaded "You have uncommitted work pending. Please commit or rollback before calling out." error, I put the error logging code in a future method, thus isolating the DML from the callouts. However, the error is still being thrown. I reduced the issue down to this pattern:
public static void foo() {
    Http http = new Http();
    HttpRequest req = new Httprequest();
    req.setEndpoint('https://test.salesforce.com'); //whatever endpoint
    req.setMethod('GET');
    http.send(req); //works fine
    bar();
    http.send(req); //throws calloutexception
}

@future public static void bar() {

}
Am I correct to assume that calling a future method counts as a DML operation? Is there any documentation I'm missing somewhere?