function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GurunathGurunath 

Problem with RelationShip query[Uregent Help]

Hi i have two objects ,can any one help me to crack the relationship fields

Budget_Building__c(parent)

Budget_Line_Item__c(child)

relationbship between is Look-up

 

in child i have one field like August_Budget_Local_Amount__c how can i retrieve this field from parent....

RaseshDave9RaseshDave9

Hi Gurunath,

You cannot do a roll up with Look up relation. You need to write a trigger, and implement the business logic.

 

Rasesh.

Subhash GarhwalSubhash Garhwal

Hi,

you can use this query for that

 

[Select Id, Name, (Select Id, August_Budget_Local_Amount__c From Budget_Line_Items) From Budget_Building__c]

 

"Budget_Line_Items" is Child Relationship Name

 

it gives you list of Budget_Line_Item__c records for a Budget_Building__c

 

For More help for SOQL query you can go through this post

 

http://blog.jeffdouglas.com/2010/02/22/soql-how-i-query-with-thee-let-me-count-the-ways/

 

Thanks

 

Hit the Kudos button (star)  and Mark as solution if it post helps you

GurunathGurunath

Hi subhash how can display the values on page by writing the nested query...............

Subhash GarhwalSubhash Garhwal

if you need a perticular records value than you can aply condition in Query or for all list use for loop

List<Budget_Building__c> bbList = [Select Id, Name, (Select Id, August_Budget_Local_Amount__c From Budget_Line_Items Where ) From Budget_Building__c];

 

for(Budget_Building__c bb : bbList) {

    if(bb.Budget_Line_Items.size() > 0) {

      

//Hold this value       

bb.Budget_Line_Items[0].August_Budget_Local_Amount__c 

 

//Or you can do it through loop

for(Budget_Line_Item__c bL : bb.Budget_Line_Items) {

   bL.August_Budget_Local_Amount__c;

 

   }

 

}

 

Thanks

 

Hit the Kudos button (star)  and Mark as solution if it post helps you