Diwali Deal : Flat 20% off + 2 free self-paced courses + $200 Voucher - SCHEDULE CALL
Apex Approval is a feature in Salesforce that allows you to automate the approval process for records such as opportunities, leads, and custom objects. If you're preparing for an interview related to Apex Approval Namespace in Salesforce, here are some potential interview questions:
Ans: The Approval namespace produces classes and methods used for approval processes. Below are some classes accessible in the Approval namespace:
Lock Result Class:
The System.Approval. lock() method returns a result for a particular record. It has the namespace "Approval."
Process Request Class:
The ProcessRequest class is the parent class for the ProcessSubmitRequest and ProcessWorkitemRequest classes. It is mainly used to write generic Apex to process Objects from either class.
Process Result Class:
The ProcessResult class is used to process the results of an approval process after submitting an approval process.
ProcessSubmit Request Class:
This class presents a record for approval.
Process Work item Request Class:
This class is used for submitting an approval request after its submission.
Unlock Result Class:
The System.Approval. lock() returns the result of an unlocked record.
Ans: The System.Approval. The lock () method displays Approval.Lock Result objects. Each respective element in a LockResult array coincides with an element ID or sObject array passed as a parameter to a lock method. The first element in the LockResult array coincides with the initial element in the ID or sObject array; the subsequent elements also coincide with their respective elements, and so on. If only one ID or sObject is passed in, the LockResult array will contain a single element.
Ans: Below are some of the methods of the LockResult class.
Methods |
Description |
Signature |
Return Value |
getErrors() |
On the appearance of an occurrence, it displays an array of one or more database error objects, producing the error code and its information. |
public List |
Type: List |
getId() |
Displays the ID of the sObject you are attempting to lock. |
public Id getId() |
Type: Id |
isSuccess() |
A Boolean value is true when the lock operation is successfully returned. |
public Boolean isSuccess() |
Type: Boolean |
Ans: The following methods of Process Request are all instance methods.
Methods |
Description |
Signature |
Return Value |
getComments() |
Displays the comments that have been added before in the approval request queue. |
public String getComments() |
Type: String |
getNextApprover Ids() |
Displays the series of user IDs of approved specified users. |
public ID[] getNextApprover Ids() |
Type: ID[] |
setComments (comments) |
Coordinates the comments to be added to the approval request. |
public Void setComments (String comments) |
Type: Void |
setNextApproverIds(nextApproverIds) |
If the next phase is another Apex approval process, one user ID must be exactly specified as the next approver. If not, this method must be null. |
public Void setNextApprover Ids( ID[] nextApproverIds) |
Type: Void |
Ans: The following methods of ProcessResult are all instance methods.
Methods |
Description |
Signature |
Return Value |
getEntityId() |
ID of the record is being processed. |
public String getEntityId() |
Type: String |
getErrors() |
On the appearance of an occurrence, it displays an array of one or more database error objects, producing the error code and its information. |
public Database.Error[] getErrors () |
Type: Database.Error[] |
getInstanceId() |
The ID of the awaiting approval process submitted for approval. |
public String getInstanceId() |
Type: String |
getInstanceStatus() |
The approval process’s current status is displayed. Some valid values are
|
public String getInstanceStatus() |
Type: String |
getNewWorkitem Ids() |
The new items submitted to the queue of approval process display their IDs. There can be 0 or 1 approval process. |
public ID[] getNewWorkitem Ids() |
Type: ID[] |
isSuccess() |
A Boolean value is set to true when the approval process is successfully completed. |
public Boolean isSuccess() |
Type: Boolean |
Ans: The Process Submit Request class also has access to all the methods in its Parent class, ProcessRequest Class.
The following methods of Process Submit Request are all instance methods.
Methods |
Description |
Signature |
Return Value |
getObjectId() |
ID of the record is being displayed, which was submitted for approval. |
public String getObjectId() |
Type: String |
getProcessDefinitionNameOrId() |
Displays the developer’s name or ID of the process definition. |
public String getProcessDefinitionNameOrId() |
Type: String |
getSkipEntryCriteria () |
It determines the entry criteria for the process(true) or not(false) when getProcessDefinitionNameOrId() displays a value other than null. |
public Boolean getSkipEntryCriteria () |
Type: Boolean |
getSubmitterId() |
The user ID of the submitter requesting the approval record is displayed and the user must be an authenticated submitter in the process definition setup. |
public String getSubmitterId() |
Type: String |
setObjectId(recordId) |
The ID of the record is set and submitted for approval. |
public Void setObjectId(String recordId) |
Type: Void |
setProcessDefinitionNameOrId(name OrId) |
Sets the developer’s name or ID of the process definition evaluation. |
public Void setProcessDefinitionNameOrId(String nameOrId) |
Type: Void |
setSkipEntryCriteria (skipEntryCriteria) |
It determines the entry criteria for the process(true) or not(false) when the process definition name or ID is not null. |
public Void setSkipEntryCriteria (Boolean skipEntryCriteria) |
Type: Void |
setSubmitterId (user ID) |
The user ID of the submitter requesting the approval record is set, and the user must be an authenticated submitter in the process definition setup. |
public Void setSubmitterId (String userID) |
Type: Void |
Ans: The ProcessWorkitemRequest class also has access to all the methods in its parent class, ProcessRequest class.
The following methods of ProcessWorkitemRequest are all instance methods.
Methods |
Description |
Signature |
Return Value |
getAction() |
Displays the action type linked with the approval request. Some of the valid values are:
|
public String getAction() |
Type: String |
getWorkitemId() |
Displays the ID of the approval request currently in the process of being approved, rejected or removed. |
public String getWorkitemId() |
Type: String |
setAction(action Type) |
An action type is set for taking an approval request processing. |
public Void setAction(String action Type) |
Type: Void |
setWorkitemId() |
Sets the ID of the approval request currently being approved, rejected, or removed. |
public Void setWorkitemId() |
Type: Void |
Ans: Below are some of the methods of the UnlockResult class.
Methods |
Description |
Signature |
Return Value |
getErrors() |
On the appearance of an error, it displays an array of one or more database error objects, producing the error code and its information. |
public List |
Type: List |
getId() |
It displays the ID of the sObject you are attempting to unlock. |
public Id getId() |
Type: Id |
isSuccess() |
When the unlock operation is successful, a Boolean value is set to true. |
public Boolean isSuccess() |
Type: Boolean |
Ans: The System. Approval. Unlock () method displays Approval.UnlockResult objects. Each element in an UnlockResult array coincides with an element ID or sObject array passed as a parameter to an unlock method. The first element in the UnlockResult array coincides with the initial element in the ID or sObject array; the subsequent elements also coincide with their respective elements, and so on. If only one ID or sObject is passed in, the UnlockResult array will contain a single element.
Enroll in a Salesforce learning program at JanBask Training to begin learning the fundamentals and more advanced courses created by industry experts to assist your progress in Salesforce.
The Approval of records in Salesforce is automated using an approval process. This process outlines every step in the approval process, including who to ask for Approval from and what to do at each stage. The Apex Approval Namespace is an indispensable tool for streamlining workflows and enhancing approval processes.
Must-Know Salesforce Apex Interview Questions and Answers
Interview Questions Based On Login Issues & Passwords
Top JWS and JWT Interview Questions and Answers
Cyber Security
QA
Salesforce
Business Analyst
MS SQL Server
Data Science
DevOps
Hadoop
Python
Artificial Intelligence
Machine Learning
Tableau
Download Syllabus
Get Complete Course Syllabus
Enroll For Demo Class
It will take less than a minute
Tutorials
Interviews
You must be logged in to post a comment