You need to sign in to do that
Don't have an account?

Related Parent Parent Field
Hi,
at the moment I get all information for the account with the code below.
Now I need the information from a related parent parent object.
Account --> Contract --> Salesnumbers
How can I get the information from the salesnumbers object?
Sascha
at the moment I get all information for the account with the code below.
Now I need the information from a related parent parent object.
Account --> Contract --> Salesnumbers
How can I get the information from the salesnumbers object?
Public List <Account> getAccDList2() { List <Account> AccD = [SELECT Id, Name, BillingCity, Rating, Billingstreet, BillingPostalCode, Folder_Link__c, NumberOfEmployees FROM Account WHERE Id = :SelectedAccountId]; RETURN AccD; }Thanks,
Sascha
Try below query
List<Salesnumber__c> fetchSalesnumbersAcc =[Select Id,Contract__c,Account.Id,Account.Name,Account.BillingCity,Account.Rating, Account.Billingstreet,Account.BillingPostalCode,Account.Folder_Link__c,Account.NumberOfEmployees FROM Salesnumber__c WHERE Contract__r.Account.Id = :SelectedAccountId];
make changes on child relationship name and field name.
Thanks,
Amit Trivedi
Contract__r.Sales_Numbers__r.fieldApiName
here I assume Contract and SalesNumbers are custom objects and there api Names are Contract__c and Sales_Numbers__c . modify you code with releavant api names
Hi Sascha,
You wont be able to query on Account to ge the fields of Salesnumber__c object as parent-child queries go upto one level below only and you want to access till second level. Try querying on Salesnumber object and fetch all account fields using "Contract__r.Account" relationship.
Thanks,
Rohini
@Sura
I get an error : Didn't understand relationship 'Contract__c__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names
@Amit
I get an error: Didn't understand relationship 'Account' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names
Any ideas?
Thanks,
Sascha
if your contract is a parent of Account and if it is a custom object systax should be as below
contract__r.Name not Contract__c__r.Name
It's a customobject. The realname is Kundenbeziehung__c (german word).
I changed the syntax, but I still get the same error. The object Kundenbeziehung__c is a parent of Account (Master).
at the Account object I have just rollup fields to the Kundenbeziehung object.
but at the Kundenbeziehung object I have a master detail field related to the Accout object.
And you have to query Kundenbeziehung__c related to accounts seperately in a diffent SOQL (subquery is possible but bit complex)
It is possible to get the information with the code below?
I tried it with the code, but I didn't get a value.
Thanks,
Sascha
i am not sure what you do with Umsatzvolumen += Umsatz.Bewertungssumme__c; line
Still not works.
Umsatzvolumen += Umsatz.Bewertungssumme__c; is to build a sum of the Bewertungssumme (values).
I checked the List Kundenbeziehung query also with a calculation and don't works too.
I posted my code below where I call the getUmsatz function. Is that correct?
Thanks,
Sascha
Thanks.