You need to sign in to do that
Don't have an account?
How to add value to each field which have field name like 'A1' , 'A2' , 'A3' using for loop
Hi,
Could you guys help me about this?
I'm newbie for programming.
I want to add value from my List to my custom fields which have sequential number as suffix of each field by using for loop.
Similar this..
Example
My custom field API name : A_1__c,A_2__c,A_3__c
List<User> userList = new List<User>();
Integer counterXX = 1;
for(User rUser : userList){
xxx.A_counterXX__c = rUser.Id;
counterXX++;
}
Can I use this logic or what it should be? Please give me some advices.
Thank you.
Could you guys help me about this?
I'm newbie for programming.
I want to add value from my List to my custom fields which have sequential number as suffix of each field by using for loop.
Similar this..
Example
My custom field API name : A_1__c,A_2__c,A_3__c
List<User> userList = new List<User>();
Integer counterXX = 1;
for(User rUser : userList){
xxx.A_counterXX__c = rUser.Id;
counterXX++;
}
Can I use this logic or what it should be? Please give me some advices.
Thank you.
xxx.put('A_' + counterXX + '__c', rUser.Id);
The first parameter of the method is the field API name in a string format. The second one is the value you want to assign to that field.
All Answers
xxx.put('A_' + counterXX + '__c', rUser.Id);
The first parameter of the method is the field API name in a string format. The second one is the value you want to assign to that field.
This solution solved my problem.