+ Start a Discussion
Bhola VishwakarmaBhola Vishwakarma 

java code to retrive data from salesforce

connection = Connector.newConnection(config1);

QueryResult queryResults1 = connection.query("Select Entity__r.Name, Acquisition_Year__c,Expected_Year_of_Sale__c,Description__c,Current_Value__c,Expected_Growth_Rate__c,Entity__c From Asset__c where Entity__c='"+userid+"'");

                    QueryResult queryResults2 = connection.query("Select Name from Account where id='"+userid+"' or parent_entity__c='"+userid+"'"); 

                    int count=queryResults2.getRecords().length;

                    if (queryResults1.getSize() > 0) {
                    for (int i1=0;i1<queryResults1.getRecords().length;i1++) {
                    Asset__c asset = (Asset__c)queryResults1.getRecords()[i1];

(asset.getEntity__r().getName())<---but here i dont get the values what is the proper logic to get the values

i have a custom object called Asset__c in that i have a custom field called as Entity__c (lookup Account)
so by using the java code i want to retrive the name of the entity using in my Asset__c 

so what should be the logic to get it



Is that relationship populated for every record in asset__c?  It's okay for entity__r to be null if the relationship is a lookup.