Skip to content

Code Routines and Embedded Code

Take advantage of Code Routines to create commonly used methods, and static values outside of a Job. Code Routines reduce the amount of embedded code required in a Job, simplifying the overall Job creation process.

Create a Formbird Code Routine

Setup a Formbird Code Routine with some common methods.

  1. From the Repository panel, create a new Code Routine, naming it FormbirdRoutine.
  2. Right-click on the new Routine, select Edit Routine Libraries and add the following external Java Libraries:

java fieldtec-webclient.jar json-simple-1.1.1.jar commons-lang3-3.3.2.jar httpcore-4.3.2.jar httpclient-4.3.4.jar handlebars-1.3.2.jar gson-2.2.4.jar commons-logging-1.2.jar

  1. Add the code below to the Routine:
package routines;

import java.util.List;

import org.apache.log4j.Logger;

import com.fieldtec.webclient.config.WebclientConfig;
import com.fieldtec.webclient.model.Document;
import com.fieldtec.webclient.service.FieldtecService;
import com.fieldtec.webclient.util.UtilJson;
import com.fieldtec.webclient.util.UtilLogger;

public class FormbirdRoutine {

    public static final String KEY_SYSTEMHEADER_TEMPLATE_ID = "systemHeader.templateId";
    public static final String KEY_SYSTEMHEADER_SYSTEM_TYPE = "systemHeader.systemType";

    public static final String SYSTEM_TYPE_DOCUMENT = "document";
    public static final String SYSTEM_TYPE_TEMPLATE = "template";

    public static final String KEY_DOCUMENT_ID = "documentId";

    static Logger logger = UtilLogger.getLogger();

    public static boolean stringHasValue(String val) {
         return val != null && !val.trim().equals("");

    public static boolean hasValue(Object val) {
         return val != null;

    public static void setupWebClientConfig(java.util.Properties context) {
        String method = "setupWebClientConfig"; + " setup webClientConfig");
        WebclientConfig wc = WebclientConfig.getInstance();

        String username = (String) context.get("username");
        String password = (String) context.get("password");
        String authUrl = (String) context.get("authUrl");
        String webserviceUrl = (String) context.get("webserviceUrl");
        String loggerName = (String) context.get("loggerName");


The Formbird Code Routine can now be called from your Jobs embedded code.

Below example demonstrates how to call the FormbirdRoutine.setupWebClientConfig method to automatically setup ftService using the values stored in context.

// Initialise ftService (always synchronize context before passing to Routine)
ftService = new FieldtecServiceImpl();

With only 3 lines of code in a Job, the ftService is now available to be used.