Diwali Deal : Flat 20% off + 2 free self-paced courses + $200 Voucher  - SCHEDULE CALL

Interview Questions on Apex Approval Namespace

Introduction

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:

Q.1. What do You Understand About The Approval Namespace in Apex?

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.

Q.2. What is The Lock Result Class Used For?

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.

Q.3. What are The Lock Result Methods?

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 getErrors()


 

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 

Q.4. What are The Process Request Class Methods?

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

Q.5. What are The Process Result Class Methods?

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 

  1. Approved,

  2. Rejected,

  3. Removed or Pending.

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 

Q.6. What are The Process Submit Request Class Methods?

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

Q.7. What are The Process Work item Request Class Methods?

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: 

  1. Approve

  2. Reject

  3. Remove

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

Q.8. What are The Unlock Result Class Methods?

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 getErrors()


 

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 

Q.9. Explain Using The Unlock Result Class.

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.

Conclusion

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.

Trending Courses

Cyber Security

  • Introduction to cybersecurity
  • Cryptography and Secure Communication 
  • Cloud Computing Architectural Framework
  • Security Architectures and Models

Upcoming Class

4 days 22 Nov 2024

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing

Upcoming Class

14 days 02 Dec 2024

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

2 days 20 Nov 2024

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum

Upcoming Class

5 days 23 Nov 2024

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design

Upcoming Class

5 days 23 Nov 2024

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning

Upcoming Class

4 days 22 Nov 2024

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing

Upcoming Class

0 day 18 Nov 2024

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation

Upcoming Class

4 days 22 Nov 2024

Python

  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation

Upcoming Class

12 days 30 Nov 2024

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks

Upcoming Class

5 days 23 Nov 2024

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning

Upcoming Class

39 days 27 Dec 2024

Tableau

  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop

Upcoming Class

4 days 22 Nov 2024