hello everyone, I'm trying to create a suiteapp p...
# sdf
b
hello everyone, I'm trying to create a suiteapp project that checks for enabled features upon validation/deployment...I used the video link below as a guide.. Executing Installation Scripts https://videohub.oracle.com/media/Executing+Installation+Scripts/1_tlcd7iij But my project passes validation and upon deployment I get the following error: An error occurred during custom object creation. Details: Script file includes @NScriptType SDFInstallationScript; this script type cannot be used to bundleinstallationscript. File: ~/Objects/customscript_install_script.xml Object: customscript_install_script (sdfinstallationscript) 2022-06-07 132853 (PST) Installation FAILED (0 minutes 4 seconds) Has anyone here been able to execute installation script in suiteapp projects?
m
yes. What does the sdf installation script deployment and your deploy.xml files look like?
🙏 1
b
Copy code
<deploy>
<run>
    <script>
        <path>~/Objects/customscript_install_script.xml</path>
        <deployment>customdeploy1</deployment>
    </script>
</run>
<files>
<path>~/FileCabinet/SuiteApps/../*</path>
</files>
<objects>
    <path>~/Objects/customscript_install_script.xml</path>
</objects>
</deploy>
Copy code
/**
 * @NApiVersion 2.0
 * @NScriptType SDFInstallationScript
 */

define(['N/runtime'], function(runtime) {
    function checkPrerequisites() {
        log.debug("SOAP WEB SERVICES check", !runtime.isFeatureInEffect({feature: 'WEBSERVICESEXTERNAL'}))
        // other feature pre-requisites: restwebservices & tba & webservicesexternal
        if (!runtime.isFeatureInEffect({
            feature: 'RESTWEBSERVICES'
        }))
            throw 'The SOAP WEB SERVICES feature must be enabled. ' +
            'Please enable the feature at Setup -> Company -> Enable Features -> SuiteCloud and try again.';
        
        if (!runtime.isFeatureInEffect({
            feature: 'WEBSERVICESEXTERNAL'
        }))
            throw 'The SOAP WEB SERVICES feature must be enabled. ' +
            'Please enable the feature at Setup -> Company -> Enable Features -> SuiteCloud and try again.';
        
        if (!runtime.isFeatureInEffect({
            feature: 'TBA'
        }))
            throw 'The SOAP WEB SERVICES feature must be enabled. ' +
            'Please enable the feature at Setup -> Company -> Enable Features -> SuiteCloud and try again.';
        
        if (!runtime.isFeatureInEffect({
            feature: 'PI_REMOVAL'
        }))
            throw 'The SOAP WEB SERVICES feature must be enabled. ' +
            'Please enable the feature at Setup -> Company -> Enable Features -> SuiteCloud and try again.';
    }
    return {
        beforeInstall: function beforeInstall(params) {
            checkPrerequisites();
        },
        beforeUpdate: function beforeUpdate(params) {
            checkPrerequisites();
        }
    };
});
m
so the new sdf installation script only has one export run
Copy code
/**
 * @NAPIVersion 2.1
 * @NScriptType SDFInstallationScript
 */
define([],

    () => {
        /**
         * Defines what is executed when the script is specified by the SDF deployment(in the deploy.xml file of an SDF project).
         * @param {Object} scriptContext
         * @param {fromVersion} scriptContext.fromVersion - The version of the SuiteApp currently installed on the account. Specify null
         *     if this is a new installation.
         * @param {toVersion} scriptContext.toVersion - The version of the SuiteApp that will be installed on the account.
         * @since 2015.2
         */
        const run = ( scriptContext ) => {
            if (!scriptContext.fromVersion) {
                log.audit("Installing for first time");
            
             }
        };
        return { run };
    });
and make sure you're using the sdf installation script type for your object. here is an example of one of mine
Copy code
<sdfinstallationscript scriptid="customscript_app_install">
  <description></description>
  <isinactive>F</isinactive>
  <name>SuiteApp | Install</name>
  <notifyadmins>F</notifyadmins>
  <notifyemails></notifyemails>
  <notifyowner>T</notifyowner>
  <notifyuser>F</notifyuser>
  <scriptfile>[/SuiteApps/...]</scriptfile>
  <scriptdeployments>
    <scriptdeployment scriptid="customdeploy_app_install">
      <isdeployed>T</isdeployed>
      <loglevel>DEBUG</loglevel>
      <status>RELEASED</status>
      <title>SuiteApp | Install</title>
    </scriptdeployment>
  </scriptdeployments>
</sdfinstallationscript>
also, if you're checking for features, you can see if any are available to declare in the manifest. I believe most of the ones you're looking for are https://system.netsuite.com/app/help/helpcenter.nl?fid=SDFxml_2917333820.html
b
Copy code
/**
 * @NAPIVersion 2.1
 * @NScriptType SDFInstallationScript
 */
is that correct?
m
Yes
b
Thanks Matt! Hopefully I can figure this out now
Thanks again Matt, got it working!
m
awesome! good to hear
🙏 1