system.mes.signature.authorization.queueAuthRequest()

Sepasoft MES Module Suite

system.mes.signature.authorization.queueAuthRequest()

This function is the foundational step of the signature workflow. Its strategic purpose is to define and register a new authorization request within the system. Here, you configure the entire process, including who is required to sign and what logic should execute for every possible outcome: a successful approval, an explicit rejection, or a failed login attempt.

Adds a new request to have one or more users sign in. When all users have signed in an action will be performed.

Parameter

Type

Purpose & Role

signatureTemplate

MESSignatureTemplate

Core Requirement: Defines the specific users and/or roles required to approve the request. This object forms the fundamental authorization rule for the workflow.

onApprove

PyFunction

Success Callback: The Python function that is executed only when all required users have successfully approved the request. This is where the primary post-approval logic resides.

onReject

PyFunction

Rejection Callback: The Python function that is executed if any required user actively rejects the request. This allows for specific handling of a denied workflow.

onError

PyFunction

Error Callback: The Python function that is executed if a user fails a login attempt due to invalid credentials or a timeout. This callback is crucial for building a user-friendly process. Use it to provide immediate feedback to the user, such as 'Invalid credentials, please try again,' rather than letting the workflow fail silently.

description
StringOptional description for the authorization request.
requestName
String

Optional title for the authorization request.


Note Available in MES 3.81.12 SP2 and MES 4.83.1 SP2 and later

Returns

This function returns a List of UUID objects. Each UUID is a globally unique identifier that represents a single signature request for one of the users required by the template. These UUIDs are essential, as they are used to invoke the correct challenge with the triggerAuthRequest() function. In a typical implementation, this list of UUIDs must be persisted or passed to the client session so that it is available when the user is ready to trigger the authentication challenge.

  • List<UUID> - A list of UUID objects that represent the requests for the different users that need to sign in.

Methods

The function offers several overloads to accommodate different levels of workflow complexity.

system.mes.signature.authorization.queueAuthRequest overloads:

  • queueAuthRequest(MESSignatureTemplate signatureTemplate obj, PyFunction onApprove, PyFunction onReject, PyFunction onError)

  • queueAuthRequest(MESSignatureTemplate signatureTemplate obj, String description, PyFunction onApprove, PyFunction onReject, PyFunction onError)

    • Use Case: The description parameter adds an optional description for the authorization request. This is valuable for logging, auditing, or displaying user-friendly context about the purpose of the signature request.

  • queueAuthRequest(MESSignatureTemplate signatureTemplate obj, String requestName, String description, PyFunction onApprove, PyFunction onReject, PyFunction onError) 

    • Use Case: Optional title for the authorization request.

Script Example

Python
def onApprove(): 
  log = system.util.getLogger("Approve"log.warn("Approve script ran")        
   
def onReject():   
  log = system.util.getLogger("Reject"log.warn("Reject script ran")        
    
def onError():        
  log = system.util.getLogger("Error")        
  log.warn("Error script ran")    
  
obj = system.mes.loadMESObject("admin", "SignatureTemplate")    
system.mes.signature.authorization.queueAuthRequest(obj, onApprove, onReject, onError)

This script first defines three simple functions to log the outcome (onApprove, onReject, onError). It then loads an MES SignatureTemplate object named "admin" and calls queueAuthRequest. Note that the script captures the returned list of UUIDs in the requestUuids variable. This is a critical step, as these unique IDs are required by the triggerAuthRequest() function to initiate the signature challenge for a specific user.

After a request is queued and its UUIDs are obtained, the next step is to use triggerAuthRequest() to present the authentication challenge to the appropriate user.



Sepasoft MES Module Suite