You need to sign in to do that
Don't have an account?
deepak1.3956330618074822E12
Trigger for date related fields
I have created a field called Hold Release Date. The Status field in the case has an entry Hold.
I am comparing the Hold Release Date to Today and trying to trigger a field update that moves from Hold to Open. But this is not happening.
Mainly because the workflow rule evaluates only for the below Evaluation Criteria
a) Created
b) Created and everytime its edited
c) Created, and any time its edited to subsequently meet criteria
Since after moving the Case to Hold status and after putting Hold Release Date, the case is not touched i.e there are no edits to that case. Since there are no edits to the case, none of the evaluation criteria is met and workflow rule is not triggered.
Example: When I put a case in Hold for lets say 7 days, the Hold Release Date would be after 7 days. In these 7 days or even probably more than 7 days, the case will not be edited at all. So the Hold Release Date is missed because no triggeres on the 7th day to move the Hold state to Open state.
Now, Salesforce support says that i can do this only using triggers.
I am new to triggers and trying to understand the Apex code (i am not a "coder" :-))
After looking into some apex triggers, i wrote my own simple code as below
trigger HoldRelease on Case (before insert) {
if (case.Hold_Release_Date__c = 'TODAY'){
case.Status = 'Open';}
}
So, when Hold Relase Date is Today, i can trigger a field update to Status to go to Open and then trigger an email.
But salesforce seems to be not liking it and giving an error which i am not able to make it out
Error Error: Compile Error: Expression cannot be assigned at line -1 column -1
Can anybody help with the above code or give me the code that can do the above job? Your help is appreciated.
Regards
Deepak
I am comparing the Hold Release Date to Today and trying to trigger a field update that moves from Hold to Open. But this is not happening.
Mainly because the workflow rule evaluates only for the below Evaluation Criteria
a) Created
b) Created and everytime its edited
c) Created, and any time its edited to subsequently meet criteria
Since after moving the Case to Hold status and after putting Hold Release Date, the case is not touched i.e there are no edits to that case. Since there are no edits to the case, none of the evaluation criteria is met and workflow rule is not triggered.
Example: When I put a case in Hold for lets say 7 days, the Hold Release Date would be after 7 days. In these 7 days or even probably more than 7 days, the case will not be edited at all. So the Hold Release Date is missed because no triggeres on the 7th day to move the Hold state to Open state.
Now, Salesforce support says that i can do this only using triggers.
I am new to triggers and trying to understand the Apex code (i am not a "coder" :-))
After looking into some apex triggers, i wrote my own simple code as below
trigger HoldRelease on Case (before insert) {
if (case.Hold_Release_Date__c = 'TODAY'){
case.Status = 'Open';}
}
So, when Hold Relase Date is Today, i can trigger a field update to Status to go to Open and then trigger an email.
But salesforce seems to be not liking it and giving an error which i am not able to make it out
Error Error: Compile Error: Expression cannot be assigned at line -1 column -1
Can anybody help with the above code or give me the code that can do the above job? Your help is appreciated.
Regards
Deepak
If you put in this:
system.debug('# # # system date: '+system.today())
;system.debug('# # # field date: '+case.Hold_Release_Date__c);
you can see what the return is in the debug log.