You need to sign in to do that
Don't have an account?
Frederik Witte 19
Update of multipicklist field not working?
Hey guys,
I wrote the following class:
global class ChangeImmo implements Schedulable{
// Execute method global void execute(SchedulableContext SC) {
List<Realty_User__c> rs = [SELECT Buttons__c FROM Realty_User__c WHERE not (Buttons__c INCLUDES ('Terminplaner'))];
for(Realty_User__c r : rs){
r.Buttons__c += ';Terminplaner';
update r;
}
}
}
Then I sheduled it for a one time run.
It worked on our testbox, but not in the live version. We have 1700 users, of which around 730 don't have the "Terminplaner". Does someone know, why this is not working?
Thank you in advance :)!
I wrote the following class:
global class ChangeImmo implements Schedulable{
// Execute method global void execute(SchedulableContext SC) {
List<Realty_User__c> rs = [SELECT Buttons__c FROM Realty_User__c WHERE not (Buttons__c INCLUDES ('Terminplaner'))];
for(Realty_User__c r : rs){
r.Buttons__c += ';Terminplaner';
update r;
}
}
}
Then I sheduled it for a one time run.
It worked on our testbox, but not in the live version. We have 1700 users, of which around 730 don't have the "Terminplaner". Does someone know, why this is not working?
Thank you in advance :)!
To resolve this error, you can use set collect all the data in set and then add that set into list adn then do the DML on that list..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
All Answers
Are you getting any error ?
You can check the debug logs or you can go and check the schedule jobs from setup adn check if it was scompleted succesfully for any error came and it failed..
Please go to setup >> then apex jobs>> then check your scheduled job executed properly or not..chck the list there..
under apex jobs it says: started at 03.04.2015 19:00. So I think it should have been executed. But I can't see any error logs?
Thank you for your time!
Can you share the screen shot of the same ?
If it is working finr in your sandbox then in live environment it is not finding the data to update but as you said there are many user where it will satisfy the condition..
Then you can check if you have update access on this object...check the permission on same object..
Thanks,
Sandeep
I just noticed, your code is not optmized it can surely hit the limit as you have done the DML inside for loop..please replace your code with this code...
list<Realty_User__c> lstRU = new list<Realty_User__c>();
for(Realty_User__c r : [SELECT Buttons__c FROM Realty_User__c WHERE not (Buttons__c INCLUDES ('Terminplaner'))])
{
r.Buttons__c += ';Terminplaner';
lstRU.add(r);
}
if(!lstRU.isEmpty())
update lstRU;
Please try with this code and let me know if it works for you..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
Can you replace your code with my code which I have provided, then you can test this first in testbox and then you can port this in your live box..
May be it is hitting the limit of DMl because in your live box there is too much data and this will not be the same in testbox..
My code is optimize and it will do only one DML but in your case with your code it will do 730 DML because you have 730 user which will satisfy the condition..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
17:00:14.574 (10574150113)|FATAL_ERROR|System.ListException: Duplicate id in list: 003b000000ZAhDgAAL
To resolve this error, you can use set collect all the data in set and then add that set into list adn then do the DML on that list..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer