You need to sign in to do that
Don't have an account?
Alex Valavanis 10
Display custom popup message while "Submitting for Approval"
Hello, I want to create a popup message alerting the users when they click on the Standard Button "Submit For Approval". I found the below link on how to do this, however i am receiving an error (Screenshot). Could you please help me? I have no experience in coding.
The Approval Process is called: "Distribution_Agreement_Onboarding"
(https://sfdcfanboy.com/2017/07/24/a-tip-a-day-2-display-custom-popup-message-while-submitting-for-approval/)
The Approval Process is called: "Distribution_Agreement_Onboarding"
(https://sfdcfanboy.com/2017/07/24/a-tip-a-day-2-display-custom-popup-message-while-submitting-for-approval/)
public class ApprovalProcessor { webservice void submitAndProcessApprovalRequest() { // Create an approval request for the account Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('Submitting request for approval.'); req1.setObjectId(a.id); // Submit on behalf of a specific submitter req1.setSubmitterId(user1.Id); // Submit the record to specific process and skip the criteria evaluation req1.setProcessDefinitionNameOrId('Distribution_Agreement_Onboarding'); req1.setSkipEntryCriteria(true); // Submit the approval request for the account Approval.ProcessResult result = Approval.process(req1); // Verify the result System.assert(result.isSuccess()); System.assertEquals( 'Pending', result.getInstanceStatus(), 'Instance Status'+result.getInstanceStatus()); )
Replace the ) in line 28(last line of this code) with }} to fix the issue.
I also see that there are few other issues with code when I tried this code snippet in my org - like it threw Compile Error: Variable does not exist: a at line 9 column 26
You need to create an account and user object variable to fix the errors.
Try below code snippet
If this information helps, please mark the answer as best.Thank you
I did foresee upcoming errors and I was in the process of editing my comment. Please try the code snippet I added in my first comment.
If this information helps, please mark the answer as best.Thank you
I also created a custom button on the Distribution Agreement Object (This is where the Approval Process is) Is what i have done correct?
How can i add the button to the page layout? I cannot see in the page layout nor in the Seach layout (?)
Then Navigate to Setup> Object Manager> Click Distribution Agreement object > You should be able to see page layouts on the left side and you should be able to add the custom button created on this Distribution Agreement object
How is this related to my scenario?
Also - Custom button doesn't show in my page layout! Please see screenshots. I have named the button "Test Button"
You will need to customize the code to reflect the custom object-"Distribution Agreement" instead of the Account. Implies you need to edit the mentioned line in your comment to
Distribution_Agreement__c d = new Distribution_Agreement__c (Name='Test');"
Regarding the button on page layout, I checked the screenshots. Please ensure you are on the right page layout of the Distribution Agreement record.
If this information helps, please mark the answer as best.Thank you