You need to sign in to do that
Don't have an account?
simon chao
Is it possible to set children name field to a field on the parent?
I want to set a parent field to a children field, is that possible?
I have a class__c (parent) within it, I have a student__c (children). The relationship between them is one to many. There can be many students within a class.
Within the class__c I have a custom field, StarPupil__c, and I want to set a student name to that field. Is that possible? Do I have to query the field or can I just assign it?
List<Class__c> tempClass = new List<Class>(); //First I want to check if class object have any students, if not I set the starPupil field to blank if( tempClass.student__r.size() == 0 ) { tempClass.starPupil__c = ' '; } // then i check to see if starpupil is equal to student name if not i set it to student name else { if(tempClass.starPupil__c != tempClass.student__r.studentName__c) { tempClass.starPupil__c = tempClass.student__r.studentName__c; } }The above code does not work as it seems that I cannot add the .studentName__c after student__r within the if statement inside the else statement. How should I approach this?
yes, it is possible but which student name you need to add, One class, contains many students right?
Check once below sample code :
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Salesforce Project Support: varaprasad4sfdc@gmail.com
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Below code will help you understand and solve your problem.
Hope this helps.