Locking Files in the SuiteApp Type of SuiteCloud Project

In SuiteCloud Development Framework (SDF), you can lock files and folders in your SuiteCloud project when that project is of type SuiteApp. After project deployment (or SuiteApp installation), a locked file or folder will appear to your SuiteApp users as read-only.

Note:

Even when using only locking preferences without hiding preferences, your SuiteCloud project must include both the locking.xml and hiding.xml files for the project to successfully deploy to a target account.

To lock files in a SuiteCloud project of SuiteApp type

  1. Create a locking.xml file in the InstallationPreferences folder of your SuiteCloud project of SuiteApp type. To create the file using a SuiteCloud IDE, see Creating an Installation Preference File with SuiteCloud IDE Plug-in for WebStorm. If you already have a locking.xml file in your SuiteCloud project, proceed directly to the next step.

  2. In the locking.xml file in your SuiteCloud project, enter values for the following attributes and fields:

    • For the type attribute of the <preference> element, specify the installation preference type to be Locking. For more information about installation preferences, see Installation Preferences in the SuiteApp of SuiteCloud Project.

    • For the defaultAction attribute of the <preference> element, specify a default locking action for all files, folders, or files and folders in your SuiteCloud project. Supported values for an action are LOCK and UNLOCK.

      Setting a value for the default action can reduce the steps when applying a preference to many files at a time. The default action applies to files in your project that are not in the apply action list of your locking.xml file. In the following example, the installation locking preference for files in the SuiteApp project is UNLOCK, so all SuiteApp files other than myScript.js are unlocked:

                          <preference type="LOCKING" defaultAction="UNLOCK">
      
          <apply action="LOCK">
      
              <path>~/FileCabinet/SuiteApps/com.example.helloWorld/myScript.js</path>
      
      </apply></preference> 
      
                        
    • For the action attribute of the <apply> element, specify a value that will apply to the files, folders, or both files and folders. Valid values are LOCK and UNLOCK. For example, <apply action="LOCK"> locks the specified files or folders.

    • For the <path> element, specify a file path for the files or folders (or both files and folders) to lock. The following are the possible ways to specify paths:

      • You can specify a path to a single file. For example, <path>~/FileCabinet/SuiteApps/com.example.helloWorld/myScript.js</path>.

      • You can specify a path to all files in a target folder (multiple files) using the wildcard (*) and the appliesTo attribute for the <path> element. For example, <path appliesTo="FILES">~/FileCabinet/SuiteApps/com.example.helloWorld/*</path>.

      • You can specify a path to all files and folders in a target folder (multiple files and folders) using the wildcard (*) and the appliesTo attribute for the <path> element. For example, <path appliesTo="FILES_AND_FOLDERS" includeRoot="F">~/FileCabinet/SuiteApps/com.example.helloWorld/myFolder/*</path>.

        To lock the root folder as well, set the attribute value includeRoot="T" on the <path> element. For example: <path appliesTo="FILES_AND_FOLDERS" includeRoot="T">~/FileCabinet/SuiteApps/com.example.helloWorld/myFolder/*</path>.

  3. Save your changes in the locking.xml file.

    When you later deploy the SuiteCloud project, to enable the values specified in the locking.xml file, you must select the Apply Installation Preferences box. For more information about selecting that preference during deployment, see Applying Installation Preferences During SuiteCloud Project Validation and Deployment.

Locking a File Using SDF Example

The following locking.xml file example locks the myScript.js file by setting the preference type to LOCKING, the default action to UNLOCK, and the apply action to LOCK, and includes a path to the file:

            <preference type="LOCKING" defaultAction="UNLOCK">

    <apply action="LOCK">

        <path>~/FileCabinet/SuiteApps/com.example.helloWorld/myScript.js</path>

</apply></preference> 

          

Locking Multiple Files Using SDF Example

The following locking.xml file example locks all files in a target folder using the wildcard (*) in the path with the appliesTo="FILES" attribute value set for the <path> element:

            <preference type="LOCKING" defaultAction="UNLOCK">

    <apply action="LOCK">

        <path appliesTo="FILES">~/FileCabinet/SuiteApps/com.example.helloWorld/*</path>

</apply></preference> 

          

Locking Files and Folders Using SDF Example

The following locking.xml file example locks all files and folders in myFolder by using the wildcard (*) and the appliesTo="FILES_AND_FOLDERS" attribute for the <path> element. The myFolder folder itself is not locked because includeRoot="F".

            <preference type="LOCKING" defaultAction="UNLOCK">

    <apply action="LOCK">

        <path appliesTo="FILES_AND_FOLDERS" includeRoot="F">~/FileCabinet/SuiteApps/com.example.helloWorld/myFolder/*</path>

</apply></preference> 

          

The following locking.xml file example locks all files and folders in myFolder, including myFolder, by using the wildcard (*) and the appliesTo="FILES_AND_FOLDERS" attribute for the <path> element with includeRoot="T".

            <preference type="LOCKING" defaultAction="UNLOCK">

    <apply action="LOCK">

        <path appliesTo="FILES_AND_FOLDERS" includeRoot="T">~/FileCabinet/SuiteApps/com.example.helloWorld/myFolder/*</path>

</apply></preference> 

          

Related Topics

Installation Preferences in the SuiteApp of SuiteCloud Project
Default Installation Preferences
Locking SDF Custom Objects in the SuiteApp Type of SuiteCloud Project
Hiding Files in the SuiteApp Type of SuiteCloud Project
Overwrite Settings for SuiteApp Projects
Applying Installation Preferences During SuiteCloud Project Validation and Deployment
Installation Preferences Validation in SuiteCloud Projects
Installation Preference File Structure in SuiteCloud Projects

General Notices