You need to sign in to do that
Don't have an account?
Kristen Lund
Setting values via Apex
Hello - I have a record that is used to create multiple other records of a different object. Our consultants wrote the code and it works great, however I'd like to reference specific field values from the original record and don't have enough code knowledge to do so.
The section of code I'd like to update is:
Hopefully this makes sense and any guidance would be much appreciated!
The section of code I'd like to update is:
Reservation__c[] newReservations = new List<Reservation__c>(); for(Id contactId:contactIds) { newReservations.add(new Reservation__c(Contact__c=contactId, Box__c = br.Box__c));br is being identified in ealier code as the primary (#1). Instead of using the main br.Box__c field, I'd like to use the specific numbered field on the original. I feel like I need to use something like br.put('Name_'+String.valueOf(i)+'_Box__c') and if(br.get('Name_' + String.valueOf(i) + '_Contact__c')!=null) but I don't know how to successfully add these to the code section.
Hopefully this makes sense and any guidance would be much appreciated!
then populate this map in a for loop of br object. Now in your for loop you can get it
Hope this make sense.
<pre>
Object boxValue = br.get( 'Name_' + br.Box__c + '_Box__c' );
List<Reservation__c> newReservations = new List<Reservation__c>();
for ( Id contactId : contactIds )
{
newReservations.add
( new Reservation__c
( Contact__c = contactId
, Box__c = boxValue
)
);
}
</pre>