You need to sign in to do that
Don't have an account?
Kieran Harrison
How to write Apex Trigger for Opportunity?
Hi Guys,
I need help writing an Apex Trigger, please. I currently have a validation rule in place which does not allow the user to move forward in Opportunity stage unless they have ticked a checkbox, however, I want to add to this rule so that they cannot move forward in stage unless they upload a customer declaration PDF under 'Files' as well as ticking the checkbox.
I have been made aware that this cannot be done using Validation Rules, however, must be done using an Apex Trigger on Opportunity.
I have taken a stab in the dark at writing the trigger from looking at Youtube videos but admittedly have absolutely no clue what I'm doing;
Any assistance is greatly appreciated.
I need help writing an Apex Trigger, please. I currently have a validation rule in place which does not allow the user to move forward in Opportunity stage unless they have ticked a checkbox, however, I want to add to this rule so that they cannot move forward in stage unless they upload a customer declaration PDF under 'Files' as well as ticking the checkbox.
I have been made aware that this cannot be done using Validation Rules, however, must be done using an Apex Trigger on Opportunity.
I have taken a stab in the dark at writing the trigger from looking at Youtube videos but admittedly have absolutely no clue what I'm doing;
Any assistance is greatly appreciated.
Please check once below snippet :
Note: I have not tested the above code may you will get some syntactical errors.
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Thanks so much for your help - Looks like there was an issue though.
Please see below;
Is there any chance you could please very briefly explain what this trigger is doing? Does it just look at whether something is uploaded to files and then allow the user to move to the next stage?
Perhaps if it is easier the trigger can look at whether a PDF was uploaded using 'Files' and then select the tick box for the field Customer_Declaration_Signed_Uploaded__c which in turn allow the user to move forward?
Use this code
Do I just need to put in the API name for the Customer Declaration field? I do not have a field called fileUpload__c ?
Thanks,
If a pdf is uploaded into the record and then showing a checkbox equals true or checked (checkbox name is fileUploaded), try like this code
Regards
Ajvad Aju
The trigger has saved successfully but I am not sure it will do exactly what I want.
All I want the trigger to do is when the user uploads the file under 'Files' (shown below in the screenshot) then tick the checkbox for the field Customer_Declaration_Signed_Uploaded__c (shown in screenshot)
It is not working - I have been testing and once I get to the correct stage then the Customer_Declaration_Signed_Uploaded__c checkbox has already been checked?