Accela Configuration for Adobe Sign

VELOSIMO_SETTINGS (Standard Choice)

Velosimo leverages a Standard Choice within Accela to associate that Accela instance to a Velosimo Tenant. The settings are defined in the table below:

The Standard Choice "VELOSIMO_SETTINGS" is required to be added into Accela

Standard Choices ValueValue Desc
VELOSIMO_ACCELA_USEREnter the username of the user defined for Velosimo integration (requires FID 0364)
VELOSIMO_TENANT_KEYThis value is provided by Velosimo per tenant
VELOSIMO_TENANT_TOKENThis value is provided by Velosimo per tenant
VELOSIMO_URLhttps://connect.velosimo.io

Example of VELOSIMO_SETTINGS Standard Choice:

1540

Velosimo Settings in Accela Adminstration

Base Velosimo EMSE Scripts

The following functions are required where your agency manages the Accela Includes_Custom script.

function sendEventToVelosimo - this functions is used to trigger calls to Velosimo

function sendEventToVelosimo(eventName, capId, docId)
{
  var vClient = new VelosimoClient();
	vClient.recordId = capId
	vClient.docId = docId
  vClient.eventName = eventName;
  res = vClient.sendRequest();
  logDebug("Response from Velosimo "+res);
}

function VelosimoClient - this function is used to lookup the Velosimo tenant key and token from the VELOSIMO_SETTINGS standard choice.

function VelosimoClient() {
  this.apiURL = lookup("VELOSIMO_SETTINGS","VELOSIMO_URL")+"/api/v2/accela/emseevents.json";
  this.eventName = null;
  this.recordId = null;
  this.docId = null;
  this.taskName = null; 
	this.taskId = null; 
	this.taskStatus = null;
  this.wfAssignedStaff = null;
  this.wfAssignedDate = null;
	this.wfDueDate = null;
  this.tenantKey = null;
  this.tenantToken = null;
	this.seamlessDocsFormId = null;

  this.buildHeaders = function () {
    var headers=aa.util.newHashMap();
    if(this.tenantKey == null)
       this.tenantKey = lookup("VELOSIMO_SETTINGS", "VELOSIMO_TENANT_KEY");
    if(this.tenantToken == null)
       this.tenantToken = lookup("VELOSIMO_SETTINGS", "VELOSIMO_TENANT_TOKEN")
    headers.put("Content-Type","application/json");
    headers.put("X-Tenant-Access-Key",this.tenantKey);
    headers.put("X-Tenant-Access-Token", this.tenantToken);
    return headers;
  }

  this.buildPostBody = function() {
    var body= {};
		var eventData = {};

    if (this.recordId != null) 
		{
			eventData.recordID = new String(this.recordId.getID1()+"-"+this.recordId.getID2()+"-"+this.recordId.getID3());
			eventData.customId = new String(this.recordId.getCustomID());
		}
  	if (this.docId != null) 
  	{
			eventData.docId = new String(this.docId);
  	}
    if(this.taskName != null)
    {
        eventData.taskName = new String(this.taskName);
    }
    if(this.taskId != null)
    {
        eventData.taskId = new String(this.taskId);
    }
    if(this.taskStatus != null)
    {
        eventData.taskStatus = new String(this.taskStatus);
    }
	if(this.wfAssignedStaff != null)
    {
        eventData.wfAssignedStaff = new String(this.wfAssignedStaff);
    }
	if(this.wfAssignedDate != null)
    {
        eventData.wfAssignedDate = new String(this.wfAssignedDate);
    }
		if(this.wfDueDate != null)
		{
			eventData.wfDueDate = new String(this.wfDueDate);
		}

		if(this.seamlessDocsFormId != null)
		{
			eventData.seamlessDocsFormId = new String(this.seamlessDocsFormId);
		}

    body.eventName = new String(this.eventName);
	  body.eventData = eventData;
		body.recordId = eventData.customId;
    var jsonBody = JSON.stringify(body);

    return jsonBody;
  }

  this.sendRequest = function() {
		logDebug("calling...");
		logDebug(this.apiURL);
		logDebug(this.buildHeaders());
		logDebug(this.buildPostBody());
    var result = aa.httpClient.post(this.apiURL, this.buildHeaders(), this.buildPostBody());
		logDebug("response...");
		logDebug(result);
    var response = result.getOutput();
		logDebug(response);
    return response;
  }
}

function velosimoGenerateReport - This function is called to generate a Report Manager report for the active Record. This report is also attached to the Accela Documents tab so the document can be sent to an Adobe envelope.

function velosimoGenerateReport(itemCap,reportName,module,parameters) {

  //returns the report file name
  var user = currentUserID;   // Setting the User Name
  var report = aa.reportManager.getReportInfoModelByName(reportName);
  report = report.getOutput();
  report.setModule(module);
  report.setCapId(itemCap);
  report.setReportParameters(parameters); 
  report.getEDMSEntityIdModel().setAltId(itemCap.getCustomID());
  var permit = aa.reportManager.hasPermission(reportName,user);

  if (permit.getOutput().booleanValue()) {
    var reportResult = aa.reportManager.getReportResult(report);
    if(reportResult) {
      reportOutput = reportResult.getOutput();
	  logDebug("report name in generate report "+reportOutput.getName());
	  return reportOutput.getName();
     
    }  else {
      logDebug("System failed get report: " + reportResult.getErrorType() + ":" +reportResult.getErrorMessage());
      return false;
    }
  } else {
    logDebug("You have no permission.");
    return false;
  }
}

function velosimoGetDocIdByReportName - This function is called to get the Document ID for the Report being used in the signature process

function velosimoGetDocIdByReportName(itemCap, reportFileName){
	var docListArray = new Array();

	docListResult = aa.document.getCapDocumentList(itemCap,"ADMIN");
	//helper_ExploreObject(docListResult);
	if (docListResult.getSuccess()) {		
		docListArray = docListResult.getOutput();
		//helper_ExploreObject(docListArray);
	}
	
	var vDocListArray = getDocumentList(capId);
	var vDocName = "";
	var vDocDownloadURL = "";

	for(iDoc in vDocListArray){
		var docModel = vDocListArray[iDoc];
		var docNo = docModel.getDocumentNo(); 
		//var docCategory = docModel.getDocCategory();
		var docName = docModel.getDocName(); 
		//var docStatus = docModel.getDocStatus();
		//logDebug(docName);
		if(docName.toUpperCase() == reportFileName.toUpperCase()){
			// Find the most current version of the document type
			logDebug("Hello " + docName + " " + docNo);
				vDocName = docName;
				return docNo
				break;
		}
		
	}
	return null;
}

Business Process EMSE Scripts

Example of DocumentUpdateAfter script:

//Setup the DocumentUpdateAfter (DUDA) to send documents for signing when the status is updated to Send to DocuSign.

if("Send to DocuSign".equals(documentModel.getDocStatus()) || "Send to Adobe Sign".equals(documentModel.getDocStatus()))
{
	sendEventToVelosimo("Sign Documents", capId, documentModel.getDocumentNo().toString());
}

Example of WorkflowTaskUpdateAfter script:

Note: this script is designed to leverage a report from Accela Report Manager, attach that document to the Accela record and then send that document for signature

//AdobeSign Start
if(wfTask == "Inspection" && wfStatus == "Send to Adobe Sign") {
		var docNumberArray = new Array();
		parameters = aa.util.newHashMap();
		parameters.put("RECORD_ID", capIDString);
		//create report
		var reportName = "";
		reportName = velosimoGenerateReport(capId,"UPDATE REPORT NAME","Building",parameters);
		if (reportName != ""){
			var documentId = velosimoGetDocIdByReportName(capId, reportName);
			
			sendEventToVelosimo("Sign Documents", capId, documentId);
		}	
	}
//AdobeSign End

What's next / Related Articles