Create, Modify, and Save Certirficate Record Based on a File in the File Cabinet

The following sample shows how to create a file object by loading a file from the File Cabinet. It then creates the options needed for the certificateControl.createCertificate(options) method and creates and saves the certificate record. The certificate record is then loaded again, edited to the change the file, and saved again.

Note:

This sample script uses the require function so that you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.

          /**
 * @NApiVersion 2.x
   */

require(['N/certificateControl','N/file'],function(cc, file){
    var fileObj = file.load({
        id: 'SuiteScripts/dsa.p12'
    });
    var options = {
        file : fileObj,
        password : '022b490ad4334c7e86a8304f937ec68f',
        name : 'testCert',
        description : 'testDescription',
        scriptId : '_testid',
        subsidiaries : [1,3],
        weekReminder : false,
        monthReminder : true,
        threeMonthsReminder : false
    };
    var newCertificate = cc.createCertificate(options);
    newCertificate.save();
 
    var loadedCertificate = cc.loadCertificate({
           scriptId : 'custcertificate_testid'
    });
    fileObj = file.load({
        id: 'SuiteScripts/ecdsa.p12'
    });
    loadedCertificate.file = fileObj;
    loadedCertificate.password = '022b490ad4334c7e86a8304f937ec68f';
    loadedCertificate.save();
}) 

        

General Notices