Timeline for Trigger if a date from a date field has been selected three times
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 11, 2014 at 17:52 | comment | added | dphil | @AndrewHoban Sorry that I don't have time to fully look into this more, but I'm currently busy at work. I just tried to give you a simple start that didn't take me too long. | |
Dec 11, 2014 at 16:53 | comment | added | Andrew Hoban | Hmm thank you. I am new to salesforce so this could be tricky. If all of them fields I mentioned previously are selected more than three times an error should appear. | |
Dec 11, 2014 at 16:51 | comment | added | dphil | @AndrewHoban Could the issue be between Select_Area__c and Area_Of_Hire__c ? You seem to have both of those fields checking the same field. I'm not sure which one you need to be checking. I think that once you get this part working you are going to need to have your aggregate query take all of that into account at once and then use a map to grab the correct one you need. | |
Dec 11, 2014 at 16:47 | comment | added | Andrew Hoban | There are no errors in the code but I am not getting the error message I need. I have created 4 different records all with 5-a-side pitch, 09:00 AM and the same date 11/12/2014. On the forth entry the error message should fire. The code you have provided has put me on the right track I think its just something small to change. | |
Dec 11, 2014 at 16:38 | history | edited | dphil | CC BY-SA 3.0 |
deleted 6 characters in body
|
Dec 11, 2014 at 16:37 | comment | added | dphil | @AndrewHoban You might be correct, I was trying to line up the checking for changing of a field with your count but I might have actually used the wrong fieldname there. You potentially need it on both places. I think I understand your question a little better now... I believe you will need a Count on that other field as well. Seems like your requirements might actually end up making this a little complex. | |
Dec 11, 2014 at 16:32 | comment | added | Andrew Hoban | Thank you. The date field I wish to check if it has already been selected is called Date_Of_Hire__c. So where you have put a.Area_Of_Hire__c != old.Area_Of_Hire__c should I change to Date_Of_Hire__c? | |
Dec 11, 2014 at 16:16 | comment | added | Andrew Hoban | My line 5 is Opportunity old = Trigger.oldMap.get(a.Id); Many thanks for your help. | |
Dec 11, 2014 at 16:15 | comment | added | dphil | @AndrewHoban What's line 5? Trigger.oldMap might be null if it's insert. I never remember the particulars and usually just do trial/error here. I edited my answer to assume that Trigger.oldMap is null on insert. | |
Dec 11, 2014 at 16:14 | history | edited | dphil | CC BY-SA 3.0 |
deleted 8 characters in body
|
Dec 11, 2014 at 16:11 | comment | added | Andrew Hoban | Thanks for this. I am using this for an insert also. When i try to insert I am getting the Error message: Error: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FiveAsideQuantityTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.FiveAsideQuantityTrigger: line 5, column 1: [] (System Code) | |
Dec 11, 2014 at 15:46 | history | answered | dphil | CC BY-SA 3.0 |