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

ERROR: Initial term of field expression must be a concrete SObject
Hi,
I am trying to create a junction object between two custom objects. I keep getting this error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Holiday__c> at line 7 column 32. Here is my code:
trigger createHoliday on Leave_Request__c (after insert) { List<LR_and_Holiday__c> lrholidaylist = new List<LR_and_Holiday__c>(); List<Holiday__c> allHoliday=[SELECT ID FROM Holiday__c Where Holiday__c.Holiday_Start_Date__c > Today]; for(Leave_Request__c insertLR : Trigger.new){ LR_and_Holiday__c lrholiday = new LR_and_Holiday__c(); lrholiday.Leave_Request__c = insertLR.ID; lrholiday.Holiday__c = allholiday.ID; lrholidaylist.add(lrholiday); } Database.insert(lrholidaylist); }
Please help.
Thank you.
At line number 7, you have accessed Id from list directly, For time being I have accessed first element of that list
you can access different records based upon index., first you need to clear which record you want to access
Thanks,
bForce
All Answers
At line number 7, you have accessed Id from list directly, For time being I have accessed first element of that list
you can access different records based upon index., first you need to clear which record you want to access
Thanks,
bForce
I would want to access all holiday records that are greater than the start date of the Leave Request Record, but less than the end date of the leave request record. I edited my SOQL statement to reflect this, but I get this error: Compile Error: unexpected token: 'startdate' at line 3 column 100. Here is my code:
Would I have to change my for loop to define a finite number of junction records that I want to create. For example, if there are three Holiday records that are between the start and end date of the Leave Request, I would want the loop to break after three loops.
Thanks for all your help.
what is API name for holiday end date on Holiday object ?
Thanks,
bForce
Holiday__c for the holiday object. Start date custom field is Start_Date__c
For Leave Request, the object API name is Leave_Request__c and Start date is Request_Start_date__c and end date is Request_End_date__c.
Thank you.