Created
          February 25, 2022 02:04 
        
      - 
      
- 
        Save Extend-Apps/b7961edb1d38bf2dd9c62248386c451d to your computer and use it in GitHub Desktop. 
    Refresh Files Suitlet (Cache Buster)
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <suitelet scriptid="customscript_refresh_files_su"> | |
| <description></description> | |
| <isinactive>F</isinactive> | |
| <name>Refresh Files</name> | |
| <notifyadmins>F</notifyadmins> | |
| <notifyemails></notifyemails> | |
| <notifyowner>T</notifyowner> | |
| <notifyuser>F</notifyuser> | |
| <scriptfile>[/SuiteScripts/RefreshFiles_SU.js]</scriptfile> | |
| <scriptdeployments> | |
| <scriptdeployment scriptid="customdeploy_refresh_files_su"> | |
| <allemployees>T</allemployees> | |
| <allpartners>T</allpartners> | |
| <allroles>T</allroles> | |
| <audslctrole></audslctrole> | |
| <eventtype></eventtype> | |
| <isdeployed>T</isdeployed> | |
| <isonline>F</isonline> | |
| <loglevel>DEBUG</loglevel> | |
| <runasrole>ADMINISTRATOR</runasrole> | |
| <status>RELEASED</status> | |
| <title>Refresh Files</title> | |
| </scriptdeployment> | |
| </scriptdeployments> | |
| </suitelet> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /** | |
| * @copyright 2021 ExtendApps, Inc. | |
| * @author Darren Hill [email protected] | |
| * @NApiVersion 2.1 | |
| * @NModuleScope SameAccount | |
| * @NScriptType Suitelet | |
| */ | |
| define(["require", "exports", "N/search", "N/file"], function (require, exports, search, file) { | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.onRequest = void 0; | |
| const onRequest = (context) => { | |
| const fileSearch = search.create({ | |
| type: 'file', | |
| filters: [ | |
| ['modified', 'after', 'minutesago10'], | |
| 'AND', | |
| ['filetype', 'anyof', 'JAVASCRIPT'] | |
| ], | |
| columns: [ | |
| search.createColumn({ name: 'name' }) | |
| ] | |
| }); | |
| let filesUpdated = 0; | |
| fileSearch.run().each(result => { | |
| try { | |
| const fileObj = file.load({ | |
| id: result.id | |
| }); | |
| fileObj.save(); | |
| filesUpdated += 1; | |
| } | |
| catch (e) { | |
| } | |
| return true; | |
| }); | |
| context.response.write(`Files Updated: ${filesUpdated}`); | |
| }; | |
| exports.onRequest = onRequest; | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment