How Do I Expand Default Script Functions for Browser Tools in Custom.Js?
    • 23 Apr 2024
    • 6 Minutes to read
    • Contributors
    • PDF

    How Do I Expand Default Script Functions for Browser Tools in Custom.Js?

    • PDF

    Article summary

    The custom.js file resides in the Transact BrowserWeb.war file and it contains a number of EFS Script functions that are called when adding web browser tools such as PDF Preview and eSignatureScan.

    Note

    These instructions are only relevant to the older Transact installations.

    While Formpipe supplies the scripts during installation, they are often updated and modified during this process, so the versions below may not always match exactly what is implemented. Despite this, the principles that are discussed can be applied to fit any version of the script.

    Note

    The filenames and paths mentioned are only relevant for ModelBank on JBOSS. The custom.js file containing these scripts may be in a different .war file or in a different path.

    The following is an example of the EFS Signature Capture button being added to the browser. It is linked to a function in the custom.js file called efs_version_launchPdfRequest_signature().

    The function is run on the Enquiry screen in Transact by editing the Enquiry and calling the function on a tool.

    The following are two functions that your Formpipe Project manager will have added into custom.js if these specific Transact interfaces were installed during the project. While they are very similar, efs_version_launchPDFRequest_signature() contains less code and includes the ability to record the version number compared to efs_version_launchPDFRequest().

    You can customize these if you want to adjust the functionality.

    For example, if you use efs_version_launchPDFRequest_signature(), you will notice two differences in the output, as compared to the output from efs_version_launchPDFRequest():

    • You may find that certain tags containing data are missing from the XML file that is generated and sent to Lasernet when clicking the SIGN DOC button.

    • You will find that the tag containing the version number is also missing from the XML file.

    LaunchPDFRequesr code:

    function efs_version_launchPdfRequest() {
        // store current form values
    
        try {
    
    
            var appreqForm = FragmentUtil.getForm(currentForm_GLOBAL);
            var previousStylesheet = appreqForm.clientStyleSheet.value;
            var previousTarget = appreqForm.target;
            var previousWindowName = appreqForm.windowName.value;
    
            // create popup and update form values
            appreqForm.windowName.value = FragmentUtil.getWindowOrFragmentName();
            appreqForm.clientStyleSheet.value = "/transforms/custom/itransform-version.xsl";
            appreqForm.target = createResultWindow("NEW", 900, 600);
            if (appreqForm.RecordRead.value == 1) {
                // we're editing the record, so run validate
                appreqForm.ofsOperation.value = _VALIDATE_;
                appreqForm.ofsFunction.value = "I";
    
                // update transaction id for security validation
                var transactionId = getFormFieldValue(currentForm_GLOBAL, "transactionId");
                transactionId = validateTransId(transactionId);
                setFormFieldValue(currentForm_GLOBAL, "transactionId", transactionId);
                checkChangedFields();
            } else {
                // we're viewing the record, so run build
                appreqForm.ofsOperation.value = _BUILD_;
                appreqForm.ofsFunction.value = "S";
            }
            FragmentUtil.submitForm(appreqForm);
    
            // reset form values
            appreqForm.clientStyleSheet.value = previousStylesheet;
            appreqForm.target = previousTarget;
            appreqForm.windowName.value = previousWindowName;
    
    
        } catch (ex) {
            alert(ex.message);
        }
    
    }

    LaunchPDFRequest-signature code:

    function efs_version_launchPdfRequest_signature() {
    
        //Get the form
        var appreqForm = FragmentUtil.getForm(currentForm_GLOBAL);
    
        //Add/update the correlationId and oneWay flag
        var correlationId = _efs_createCorrelationId();
        _efs_addOrUpdateInputWithValue(appreqForm, _efs_correlationId, correlationId);
        _efs_addOrUpdateInputWithValue(appreqForm, _efs_noResponse, "true");
    
        //update the style sheet
        appreqForm.clientStyleSheet.value = "/transforms/custom/itransform-version.xsl";
    
        //set the global transaction id for some reason
        transactionId = appreqForm.transactionId.value;
    
        //grab the version and update
        var savedVersion = appreqForm.version.value;
        appreqForm.version.value = "";
    
        //grab the routine args and update
        var savedRoutineArgs = appreqForm.routineArgs.value;
        appreqForm.routineArgs.value = "1";
    
        //grab the target and update to a background iframe
        _efs_addHiddenIFrame(_efs_backgroundWorker_response);
        var savedTarget = appreqForm.target;
        appreqForm.target = _efs_backgroundWorker_response;
    
        //grab the window name and update
        var savedWindowName = appreqForm.windowName.value;
        appreqForm.windowName.value = window.name;
    
        //some other form changes
        appreqForm.routineName.value = "";
        appreqForm.ofsFunction.value = "I";
        appreqForm.ofsOperation.value = _BUILD_;
        appreqForm.requestType.value = _OFS__APPLICATION_;
    
        //submit the form and revert saved changes
        FragmentUtil.submitForm(appreqForm);
        appreqForm.target = savedTarget;
        appreqForm.windowName.value = savedWindowName;
        appreqForm.version.value = savedVersion;
        appreqForm.routineArgs.value = savedRoutineArgs;
        appreqForm.clientStyleSheet.value = "";
    
        //start the client
        _efs_addHiddenIFrame(_efs_backgroundWorker_client);
        //var appUrl = "pdmclient://Signature Application/search=eSignature/parameters={correlationId:"+ correlationId + "}/engine=tablet";
        var appUrl = "pdmclient://Signature Application/search=eSignature/parameters={correlationId:" + correlationId + "}/engine=wacom";
        window.open(appUrl, _efs_backgroundWorker_client);
    }

    While they are similar, the biggest difference with the eSignature function is that some of the tags and data, as well as the version number, are not sent in the XML. To add this functionality to the eSignature interface, you need to replace the existing code:

    appreqForm.ofsFunction.value = "I";
    appreqForm.ofsOperation.value = _BUILD_;

    with the following code from efs_version_launchPDFRequest():

     if (appreqForm.RecordRead.value == 1) {
         // we're editing the record, so run validate
         appreqForm.ofsOperation.value = _VALIDATE_;
         appreqForm.ofsFunction.value = "I";
     
         // update transaction id for security validation
         var transactionId = getFormFieldValue(currentForm_GLOBAL, "transactionId");
         transactionId = validateTransId(transactionId);
         setFormFieldValue(currentForm_GLOBAL, "transactionId", transactionId);
         checkChangedFields();
     } else {
         // we're viewing the record, so run build
         appreqForm.ofsOperation.value = _BUILD_;
         appreqForm.ofsFunction.value = "S";
     }

    It can be seen from the line of code in efs_version_launchPDFRequest_signature() that the version is being set to blank: appreqForm.version.value = "";.

    This means that it will not appear in the XML. However, if the above line is commented out, the function will set the version number and it will be sent in the XML.

    The function below shows the result of making the above edits to the standard efs_version_launchPDFRequest_signature() function in custom.js. While some functions will differ slightly in appearance, the outcome should be identical if the edits are carried out carefully.

    function efs_version_launchPdfRequest_signature() {
        //Get the form
        try {
            document.getElementById("version").value = document.getElementById("version").value + ".SIGN";
            var appreqForm = FragmentUtil.getForm(currentForm_GLOBAL);
            //Add/update the correlationId and oneWay flag
            var correlationId = _efs_createCorrelationId();
            _efs_addOrUpdateInputWithValue(appreqForm, _efs_correlationId, correlationId);
            _efs_addOrUpdateInputWithValue(appreqForm, _efs_noResponse, "true");
            //update the style sheet
            appreqForm.clientStyleSheet.value = "/transforms/custom/itransform-version.xsl";
            //set the global transaction id for some reason
            transactionId = appreqForm.transactionId.value;
            //grab the version and update
            var savedVersion = appreqForm.version.value;
            //appreqForm.version.value = "";
            //grab the routine args and update
            var savedRoutineArgs = appreqForm.routineArgs.value;
            appreqForm.routineArgs.value = "1";
            //grab the target and update to a background iframe
            _efs_addHiddenIFrame(_efs_backgroundWorker_response);
            var savedTarget = appreqForm.target;
            appreqForm.target = _efs_backgroundWorker_response;
            //grab the window name and update
            var savedWindowName = appreqForm.windowName.value;
            appreqForm.windowName.value = window.name;
            appreqForm.routineName.value = "";
            if (appreqForm.RecordRead.value == 1) {
                // we're editing the record, so run validate
                appreqForm.ofsOperation.value = _VALIDATE_;
                appreqForm.ofsFunction.value = "I";
                // update transaction id for security validation
                var transactionId = getFormFieldValue(currentForm_GLOBAL, "transactionId");
                transactionId = validateTransId(transactionId);
                setFormFieldValue(currentForm_GLOBAL, "transactionId", transactionId);
                checkChangedFields();
            } else {
                // we're viewing the record, so run build
                appreqForm.ofsOperation.value = _BUILD_;
                appreqForm.ofsFunction.value = "S";
            }
            //some other form changes
            //appreqForm.ofsFunction.value="S";
            //appreqForm.ofsOperation.value=_BUILD_;
            appreqForm.requestType.value = _OFS__APPLICATION_;
            //submit the form and revert saved changes
            FragmentUtil.submitForm(appreqForm);
            appreqForm.target = savedTarget;
            appreqForm.windowName.value = savedWindowName;
            appreqForm.version.value = savedVersion;
            appreqForm.routineArgs.value = savedRoutineArgs;
            appreqForm.clientStyleSheet.value = "";
            //start the client
            _efs_addHiddenIFrame(_efs_backgroundWorker_client);
            //var appUrl = "pdmclient://Signature Application/search=eSignature/parameters={correlationId:"+ correlationId + "}/engine=tablet";
            var appUrl = "pdmclient://Signature Application/search=eSignature/parameters={correlationId:" + correlationId + "}/engine=wacom";
            window.open(appUrl, _efs_backgroundWorker_client);
        } catch (ex) {
            alert(ex.message);
        }
    }


    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.