Q-assign Assignment API

Do you want to learn how to use the Q-assign Assignment API?

If you're looking to use the Q-assign Assignment API, you've come to the right place! This article will walk you through the basics of using the API.


Entry Point to the API

The Q-assign package includes a global class called QassignAPI_Assignment that serves as the entry point to the API. This class exposes methods that allow third-party code or applications to perform assignment-related operations.


Method: Constructor for QassignAPI_Assignment

The constructor creates an instance of QassignAPI_Assignment and initializes internal data for the object. If the object initialization is successful, any of its global methods can be called. If initialization fails for any reason, an exception of type QassignAPI_AssignmentException is thrown with details about the error.





Method: runOneAssignmentGroup_v1

This method will have two overloads:


Overload 1

This function is primarily used when the caller has already fetched data from the database and wants that list of records to be updated or processed by the API call. An important use case for this API is when it is called from within a trigger, where the list of objects is already in memory. Note that this overload doesn't perform DML operations on the records; it only changes the owner of the records in memory. It's the responsibility of the caller to perform the final DML operations. This is especially useful for calling the API from 'before' triggers, where DML is handled by the platform.



  • List<SObject> - List of objects to be passed to AG to process.

  • AssignmentGroupIdOrName: String - Id or Name of the assignment group to run


Overload 2

This function is mainly used when the caller either doesn't want to load records or only has access to the IDs of the records. This overload performs the DML operations itself. In other words, the records that get assigned will be updated in the database with the new owner (or any other assignment type defined by the Assignment Group).



  • List<ID> RecordIdList: - List of record Ids to pass to the AG to process

  • String AssignmentGroupIdOrName: String - Id or Name of the assignment group to run



List< QassignAPI_Assignment.AssignmentResult> contains an ordered list of AssignmentResult having data regarding assignment of record, there will be an AssignmentResult for each passed record for assignment. If no assignment is made, then AssignmentResult.userId will be set to null. Records are returned in the same order as the parameter list, i.e. the first record is returned at index 0, and second on index 1, and so on.


AssignmentResult is a custom class that has the following members.

  • userId: Id - the ID of the user, to whom the record was assigned to. Null if no assignment is made
  • recordId: Id - the ID of the record that got processed for assignment
  • status: assignment status message



This function takes a Record (parameter: RecordId), an Assignment Group Id, or a Name (parameter: AssignmentGroupIdOrName). It performs the pre-conditions below and if any of them fail, it returns an exception of type QassignAPI_AssignmentException.

  • Record IDs passed to the API are valid.
  • AssignmentGroupIdOrName contains a valid Id or non-empty string
  • AssignmentGroupIdOrName refers to an existing Assignment Group
  • Assignment Group processing type is Push or Push + Pull
  • Record IDs is for a record that is the target object of the identified Assignment Group
  • Assignment Group is enabled
  • Selection Criteria match the passed-in records

Example API call

// Retrieve the Case record with the specified ID

Case recordId = [SELECT Id, OwnerId FROM Case WHERE Id = '5004L00000LkuBvQAJ'];


// Create a new list to store the Case record

List<Case> listOfRecordIds = new List<Case>();


// Add the retrieved Case record to the list



// Assign the name or ID of the assignment group to a variable

String assignmentGroupNameOrId = 'Case Simple RR01';


// Create an instance of the QassignAPI_Assignment class

ortoo_qra.QassignAPI_Assignment API = new ortoo_qra.QassignAPI_Assignment();


// Run the assignment for the given list of leads and assignment group

API.runOneAssignmentGroup_v1(listOfRecordIds, assignmentGroupNameOrId);



Please contact us at support@ortooapps.com for any questions.


Was this information helpful?