You need to sign in to do that
Don't have an account?
Eugene Ritenband
Need help with an Apex Trigger to Update a Checkbox field after a Document is uploaded
Hi All,
I am very new to writing triggers and need some help on this one. On the Opportunity object, there is a custom checkbox field called "Invoice Attached". When an Invoice is uploaded to that Opp, I would like the checkbox will be marked. I have attached my Trigger and Test Class. Any help would be greatly appreciated.
I am very new to writing triggers and need some help on this one. On the Opportunity object, there is a custom checkbox field called "Invoice Attached". When an Invoice is uploaded to that Opp, I would like the checkbox will be marked. I have attached my Trigger and Test Class. Any help would be greatly appreciated.
Take a look at this post as it might be helpful.
Updating a checkbox field if a File is uploaded through ContentDocumentLink trigger (https://developer.salesforce.com/forums/?id=9060G0000005Me4QAE)
You might consider using a Lightning Flow Screen to guide the user in the file upload process and include an update for the "Invoice_Attached__c" field. Otherwise, it may not be certain to know if the file is an invoice or some errant file.
All Answers
Take a look at this post as it might be helpful.
Updating a checkbox field if a File is uploaded through ContentDocumentLink trigger (https://developer.salesforce.com/forums/?id=9060G0000005Me4QAE)
You might consider using a Lightning Flow Screen to guide the user in the file upload process and include an update for the "Invoice_Attached__c" field. Otherwise, it may not be certain to know if the file is an invoice or some errant file.
Thanks for sending over the link. I will take a look at it. Thank you!
-Eugene
I am hoping you can help me with this. I got the trigger to fire and the checkbox is now checked, but in order to have the checkbox checked, I need to refresh the page. Is there a way to have the checkbox checked without having to refresh the page? Thank you!
The data is committed to the database, even if the UI isn't updated. I presume this is an issue for you in the Lightning UI as in my experience this works as expected and updates the screen in Classic when adding a file.
To trigger a refresh in Lightning for this scenario it appears a bit more is required as the trigger will also need to publish a platform event that can be received by a component to run a "force:refreshView". I haven't looked into this much further, so this may not even be possible.
Here is an alternative to using the Apex trigger: