+ Start a Discussion
SimrinSimrin 

Retrieve custom columns from Custom object

Hello,

I have a use case to retrive few columns form a custom object.
Belwo is my use case.
I use SOQL to retrive a User.FirstName, User.LastName from ProfileSkillUser.
I want to retrive two more fields Practice__c and Team__c from UserAdditionalInformation__c which has User__c as look up.

User__c in UserAdditionalInformation__c should match User in ProfileSkillUser. 

List<ProfileSkillUser> pList = SELECT User.FirstName, User.LastName, ProfileSkill.Name,Skill_assessment__c FROM ProfileSkillUser;

ProfileSkillUser
-User-User-Lookup(User)
User
 -Name - Name - Name
-Username - Username -Text(80)
-Other User fields

UserAdditionalInformation__c
-User-User__c-Lookup(User)
-Team-Team__c-Lookup(Team)
-Practice-Practice__c-Lookup(Team Practice)


Best Answer chosen by Simrin
ManojjenaManojjena
Hi Simrin,

What I understood from your requirment user is the parent to profileSkilluser (StandradObject ) also User is the parent of UserAdditionalInformation__c  (custom object ) .I don't think you have any relationship from profileSkill user to UserAdditionalInformation__c .

So I don't think you can get all information in one query .As parent to child you can query only one label deep .
As user is the parent of ProfileSkill and UserAdditionalInformation  and there is no relationship between profileskill and userAdditionalInformation .So it is difficult to indentify which userprofile skill has additional information .Again is there any thing like you can create only one userAdditionalInformation  for one user ? If yes then we can achieve this through mapping .

To understand the detail about the relationship query you can install below app from appexchange which has only 5-6 scontroll means webpage which will help to built the relatonship query with many level as possible .
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016bGoEAI  

Check below link it will give you soem information about the relationship query .

https://developer.salesforce.com/blogs/developer-relations/2013/05/basic-soql-relationship-queries.html  

You can down load below pdf to know more detail about SOQL and SOSl .

https://resources.docs.salesforce.com/194/latest/en-us/sfdc/pdf/dbcom_soql_sosl.pdf

let me know if it helps .

Thanks 
Manoj




 

All Answers

NagaNaga (Salesforce Developers) 
Hi Simrin,

Please see a sample code and link below for more information.

User-added imagePlease see the link below

https://jungleeforce.wordpress.com/2013/06/07/extracting-list-of-all-the-objects-standard-custom-in-salesforce/

Best Regards
Naga Kiran
ManojjenaManojjena
Hi Simrin,

What I understood from your requirment user is the parent to profileSkilluser (StandradObject ) also User is the parent of UserAdditionalInformation__c  (custom object ) .I don't think you have any relationship from profileSkill user to UserAdditionalInformation__c .

So I don't think you can get all information in one query .As parent to child you can query only one label deep .
As user is the parent of ProfileSkill and UserAdditionalInformation  and there is no relationship between profileskill and userAdditionalInformation .So it is difficult to indentify which userprofile skill has additional information .Again is there any thing like you can create only one userAdditionalInformation  for one user ? If yes then we can achieve this through mapping .

To understand the detail about the relationship query you can install below app from appexchange which has only 5-6 scontroll means webpage which will help to built the relatonship query with many level as possible .
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016bGoEAI  

Check below link it will give you soem information about the relationship query .

https://developer.salesforce.com/blogs/developer-relations/2013/05/basic-soql-relationship-queries.html  

You can down load below pdf to know more detail about SOQL and SOSl .

https://resources.docs.salesforce.com/194/latest/en-us/sfdc/pdf/dbcom_soql_sosl.pdf

let me know if it helps .

Thanks 
Manoj




 
This was selected as the best answer