You need to sign in to do that
Don't have an account?
sasham
Pls anyone help on this
I have all participant and states object (two records registered and assessed ). for some participant is not assesed inthe table evethough it is actually assessed. need to insert those records to states as assesesd
i have list of patticipant ids and list of states as assessed
if(recs.size()>0 && participantsatates.size()>0)
{
for(participant__c p:recs)
{
for(States__c pstate :participantsatates)
{
IF (P.Id = pstate.Participant__c)
{
}
}
}
i have list of patticipant ids and list of states as assessed
if(recs.size()>0 && participantsatates.size()>0)
{
for(participant__c p:recs)
{
for(States__c pstate :participantsatates)
{
IF (P.Id = pstate.Participant__c)
{
}
}
}
Try this,
Thanks,
If it helps you, please mark is as best answer, so it will be helpful for other developers.
All Answers
Your code is not clear, could you answer for the below:
1. what is the assessed record id?
2. what is the API name for the states in participant object? Did you create lookup field in Participant?
3. For all the participant records need to update states as assessed ?
Thanks,
Participant - Participantt_c
State - state (picklist as registered and assesesd) ,, Participantt_c look up ,
I have all the participant ids which is matched form other table
List < Participantt_c > par = List < Participantt_c >()
List <id> pid = List <id>()
need to insert state table if there is no state like assesed
Participant - Participantt_c
State - Participantt_c (look up field), states( picklist as egistered and assesesd)
queriyng all participants whch match the od form other object and see if there is a state as assesed for ecah participant , if not need to insert one
Try this,
Thanks,
If it helps you, please mark is as best answer, so it will be helpful for other developers.
The code is fine, it does not throws any governor limits.
In line 42, correct as stateObj.State__c =statesRec; //statesRec is a string field, you are using as statesRec.id
If you not using PsRecsById other than in line 23. you can remove it and directly add the ids in line
as below: replace line 15 - 23.
Thanks,
I hope you will not get any limit exception, since you're using where condition in your SOQL Query statement.
If you got any issue, post it and will check on it
(or)
Need to go with Batch class
Batch Class Reference: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
Thanks,
If it helps you, please mark is as best answer, so it will be helpful for other developers.
Just one question .I am yf page and the button. From the controller is it possible to run bacth . I mean i cn craete a batch class and intaiting form the controller calss when clicking on the button, or ineed to craete batch class
and other question. if i create a helper calss for this controller , . so that i can reduce the governer limit.
If you need do bulk operation, then you can go with Batch Class.
VF Question:
You can call the batch class from the controller.
BatchClass obj = BatchClass();
Database.executeBatch(obj);
Reference: https://success.salesforce.com/answers?id=90630000000hkxlAAA
Thanks..