I have following JS which is added in header. I have button in page. I want to call "FulfillOrder" function of JS.

I don't know how to call it.

Can anybody please suggest me how can I call?

JS:

```
/// <reference path='../../../../ClientCommon/Sales_ClientCommon.d.ts' />
/// <reference path="../../../../../../TypeDefinitions/CRM/ClientUtility.d.ts" />
/// <reference path='../../../../CommandBarActions/SalesCommandBarActions.d.ts' />
var Sales;
(function (Sales) {
    var SalesOrderRibbonActionsLibrary = (function () {
        function SalesOrderRibbonActionsLibrary() {
            var _this = this;
            this.CloseOrFulfillOrder = function (closedState) {
                var options = { height: 350, width: 475, position: 1 /* center */ };
                options.width = 330;
                options.height = 400;
                var dialogParams = {};
                dialogParams[Sales.MetadataDrivenDialogConstantsOrderClose.SalesId] = Xrm.Page.data.entity.getId();
                dialogParams[Sales.MetadataDrivenDialogConstantsOrderClose.ClosedState] = closedState;
                Xrm.Navigation.openDialog(Sales.DialogName.CloseOrder, options, dialogParams).then(_this.salesOrderDialogCloseCallback);
            };
            this.salesOrderDialogCloseCallback = function (response) {
                var parameters = response.parameters;
                var lastButtonClicked = parameters[Sales.MetadataDrivenDialogConstantsOrderClose.LastButtonClicked];
                if (ClientUtility.DataUtil.isNullOrUndefined(lastButtonClicked) || lastButtonClicked.toString() !== ClientUtility.MetadataDrivenDialogConstants.DialogOkId) {
                    return;
                }
                var salesOrderId = parameters[Sales.MetadataDrivenDialogConstantsOrderClose.SalesId];
                var date = new Date(parameters[Sales.MetadataDrivenDialogConstantsOrderClose.Date]);
                var closedState = parseInt(parameters[Sales.MetadataDrivenDialogConstantsOrderClose.ClosedState]);
                var reason = parseInt(parameters[Sales.MetadataDrivenDialogConstantsOrderClose.Reason]);
                var description = null;
                if (!ClientUtility.DataUtil.isNullOrUndefined(parameters[Sales.MetadataDrivenDialogConstantsOrderClose.Description])) {
                    description = parameters[Sales.MetadataDrivenDialogConstantsOrderClose.Description].toString();
                }
                if (!ClientUtility.DataUtil.isNullOrUndefined(date) && !ClientUtility.DataUtil.isNullOrUndefined(date)) {
                    _this.commandBarActions.PerformActionAfterCloseOrder(reason, date, description, closedState, salesOrderId);
                }
            };
            /**
             * Processes the sales order.
             */
            this.ProcessOrder = function () {
                if (Xrm.Page.ui.getFormType() !== 4 /* Disabled */ && Xrm.Page.ui.getFormType() !== 3 /* ReadOnly */) {
                    Xrm.Page.data.save().then(function (successResponse) {
                        _this.processOrderSuccessResponse();
                    }, ClientUtility.ActionFailedHandler.actionFailedCallback);
                }
                else {
                    _this.processOrderSuccessResponse();
                }
            };
            this.processOrderSuccessResponse = function () {
                var columns = new ODataContract.ColumnSet(false, ["invoiceid"]);
                if (!_this.IsBackOfficeInstalled()) {
                    var convertSalesOrderToInvoiceRequest = new ODataContract.ConvertSalesOrderToInvoiceRequest();
                    convertSalesOrderToInvoiceRequest.SalesOrderId = { guid: Xrm.Page.data.entity.getId() };
                    convertSalesOrderToInvoiceRequest.ColumnSet = columns;
                    Xrm.WebApi.online.execute(convertSalesOrderToInvoiceRequest).then(function (response) {
                        response.json().then(function (jsonResponse) {
                            var invoiceId = jsonResponse.invoiceid;
                            Xrm.Utility.openEntityForm(Sales.EntityNames.Invoice, invoiceId, null);
                        });
                    }, ClientUtility.ActionFailedHandler.actionFailedCallback);
                }
                else {
                    var defaultStatusCode = -1;
                    XrmCore.Commands.Common.setState(Xrm.Page.data.entity.getId(), Xrm.Page.data.entity.getEntityName(), Sales.SalesOrderState.Submitted, defaultStatusCode);
                }
            };
            this.IsBackOfficeInstalled = function () {
                // var isBackOfficeInstalled: string = Xrm.Internal.getResourceString("IS_BACKOFFICE_INSTALLED");
                // if (ClientUtility.DataUtil.isNullOrEmptyString(isBackOfficeInstalled)) {
                //     return false;
                // }
                // return isBackOfficeInstalled === "1";
                //TODO: investigate backoffice.
                return false;
            };
            this.GetProductsForOrder = function () {
                _this.commandBarActions.getProducts();
            };
            this.LockSalesOrder = function () {
                debugger;
                _this.commandBarActions.lock();
            };
            this.UnlockSalesOrder = function () {
                debugger;
                _this.commandBarActions.unlock();
            };
            this.CloseOrder = function () {
                _this.CloseOrFulfillOrder(Sales.SalesOrderState.Canceled);
            };
            this.FulfillOrder = function () {
                _this.CloseOrFulfillOrder(Sales.SalesOrderState.Fulfilled);
            };
            this.IsSalesOrderActive = function () {
                return _this.IsSalesOrderState(Sales.SalesOrderState.Active);
            };
            this.IsSalesOrderFulfilled = function () {
                return _this.IsSalesOrderState(Sales.SalesOrderState.Fulfilled);
            };
            this.IsSalesOrderSubmitted = function () {
                return _this.IsSalesOrderState(Sales.SalesOrderState.Submitted);
            };
            this.IsSalesOrderState = function (state) {
                var stateCodeControl = Xrm.Page.data.entity.attributes.get("statecode");
                var orderState = stateCodeControl ? stateCodeControl.getValue() : null;
                var returnValue = false;
                if (ClientUtility.DataUtil.isNullOrUndefined(orderState)) {
                    return returnValue;
                }
                switch (state) {
                    case 0:
                        if (orderState === 0) {
                            returnValue = true;
                        }
                        break;
                    case Sales.SalesOrderState.Submitted:
                        if (orderState === Sales.SalesOrderState.Submitted) {
                            returnValue = true;
                        }
                        break;
                    case Sales.SalesOrderState.Fulfilled:
                        if (orderState === Sales.SalesOrderState.Fulfilled) {
                            returnValue = true;
                        }
                        break;
                    case Sales.SalesOrderState.FulfilledOrActive:
                        if (orderState === Sales.SalesOrderState.Fulfilled || orderState === 0) {
                            returnValue = true;
                        }
                        break;
                    default:
                        returnValue = false;
                        break;
                }
                return returnValue;
            };
        }
        Object.defineProperty(SalesOrderRibbonActionsLibrary.prototype, "commandBarActions", {
            get: function () {
                if (ClientUtility.DataUtil.isNullOrUndefined(this._commandBarActions)) {
                    this._commandBarActions = new Sales.SalesCommandBarActions();
                }
                return this._commandBarActions;
            },
            enumerable: true,
            configurable: true
        });
        return SalesOrderRibbonActionsLibrary;
    }());
    Sales.SalesOrderRibbonActionsLibrary = SalesOrderRibbonActionsLibrary;
})(Sales || (Sales = {}));
/**
* @license Copyright (c) Microsoft Corporation. All rights reserved.
*/
/// <reference path="../../../../../TypeDefinitions/CRM/ClientUtility.d.ts" />
/// <reference path="UCI/SalesOrderRibbonActionsLibrary.ts" />
/// <reference path="../../../../../../references/internal/TypeDefinitions/XrmClientApi/XrmClassicWebClientApi.d.ts" />
var Sales;
(function (Sales) {
    var SalesOrderRibbonActions = (function () {
        function SalesOrderRibbonActions() {
        }
        return SalesOrderRibbonActions;
    }());
    SalesOrderRibbonActions.Instance = new Sales.SalesOrderRibbonActionsLibrary();
    Sales.SalesOrderRibbonActions = SalesOrderRibbonActions;
})(Sales || (Sales = {}));
//# sourceMappingURL=SalesOrderRibbonActions.js.map

```

Previous version of this JS have function "fulfillOrder" and it was working properly. But in this version, they updated a lot. I don't know how to call it.

Please suggest.

[![enter image description here](https://i.stack.imgur.com/Ea7ci.png)](https://i.stack.imgur.com/Ea7ci.png)
Thank you.