Update script parameter field value in company preference

Hi Guys, How do i update script parameter field value in company preference thru script?

Beginner Asked on July 8, 2021 in SuiteScript.
Add Comment
2 Answer(s)

Use N/config to load the general preferences record and set it and save the record.

Intermediate Answered on July 8, 2021.
Add Comment

Please follow the below code snippet:

/**
 * companyPreferences.js
 * @NApiVersion 2.x
 * @NModuleScope Public
 */
//Sample Config load and get Value or set Value
define(['N/config'],
    function (config) {
    //Please visit config module for types in help
        function loadCompanyPreferences() {
            const shopifyApi = config.load({
                type: config.Type.COMPANY_PREFERENCES //depends on your requirement
            });
            const apiKey = shopifyApi.getValue('field ID');
            shopifyApi.setValue('field ID', 'value');
            shopifyApi.save(); //You can use the ignore or field sourcing
        }

        return {
            compPref: loadCompanyPreferences
        }

    });
Beginner Answered on July 8, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor