+ Start a Discussion

return custom obect with custom object member


I have custom object X which has many custom members including Account(datatype is Lookup(Account)) which is related to Account object. When I create instance of getXInfoService in .net code after consuming webservice, I see x.Account__c and x.Account__r. Account__c is string and Account__r is null. How can I get Account object thru apex webservice?

global class getXInfo {

WebService static X__c getX(string xName) {

   X__c  z= [SELECT Account__c, API_Access__c from X__c WHERE X__c.Name =: xName];

    X__c n_z= new X__c(Account__c = z.Account__c, API_Access__c=z.API_Access__c);

   return n_z;


Maybe try selecting the object you just inserted and including the fields you need, and then returning the results of that select instead.