Arnob Dep
Arnob Dep

Reputation: 1

I want to add "save & edit" button in Item fulfillment, when click on the button transaction will save and open in edit mode

Add a button "save & edit" in transaction form (item fulfillment) and when click the button then the record will save and open in edit mode. I have tried using event and client script, but it give me an error that rec.save( ) is not a function. Looking into oracle I found out that .save() function didn't work on Client script. What will be the possible solution for this issue? is there any other way around?

Event script: /**

    var exports = {};

    function pageInit(context) {
    }
    function onButtonClick() {

        var rec = currentRecord.get();

        rec.save({
            ignoreMandatoryFields: false
        }).then(function(recordId) {
            // After saving, redirect back to edit mode using the record ID
            var baseUrl = url.resolveRecord({
                recordType: rec.type,
                recordId: recordId,
                isEditMode: true
            });

            // Redirect to edit mode of the saved record
            window.location.href = baseUrl;
        }).catch(function(error) {
            console.error('Error during save:', error.message);
        });
    

    }

    exports.onButtonClick = onButtonClick;
    exports.pageInit = pageInit;
    return exports;
});

/**


    function beforeLoad(context) {
        var form = context.form;

        if ( context.type === context.UserEventType.EDIT) {
            
            // Add a custom button for "Save and Edit"
            form.addButton({
                id: 'custpage_save_and_edit',
                label: 'Save and Edit',
                functionName: 'onButtonClick'
            });

            // Link the client script for button functionality
            form.clientScriptModulePath = 'SuiteScripts/.js'; // Link to the Client Script
        }
    }

    return {
        beforeLoad: beforeLoad
    };
});

Upvotes: 0

Views: 63

Answers (0)

Related Questions