ehcanadian
12/12/2018, 3:32 PMjkabot
12/12/2018, 3:38 PMexport function getScriptFileId(scriptId: string): string {
const results = search.create({
type: 'script',
filters: ['scriptid', 'is', scriptId],
columns: ['scriptfile']
}).run().getRange({ start: 0, end: 1 });
if (results.length === 0) {
return '';
}
return results[0].getValue('scriptfile');
}
const scriptFileId = getScriptFileId(runtime.getCurrentScript().id);
const scriptFile = file.load({ id: scriptFileId });
const lastSlash = scriptFile.path.lastIndexOf('/');
const scriptFolderPath = scriptFile.path.substring(0, lastSlash);
const relativeFile = file.load({ id: `${scriptFolderPath}/path/to/relative/file` });
ehcanadian
12/12/2018, 3:40 PMVaid
12/12/2018, 3:44 PMjkabot
12/12/2018, 3:46 PMVaid
12/12/2018, 3:50 PMVaid
12/12/2018, 3:50 PMVaid
12/12/2018, 3:51 PMjkabot
12/12/2018, 3:53 PMVaid
12/12/2018, 3:53 PMjkabot
12/12/2018, 3:55 PMVaid
12/12/2018, 3:56 PMjkabot
12/12/2018, 3:58 PMstalbert
12/12/2018, 4:08 PMehcanadian
12/12/2018, 4:14 PM'../../Templates/my_template.xml'
would be the same as 'SuiteScripts/Traveler/Templates/my_template.xml'
?jkabot
12/12/2018, 4:17 PM'SuiteScripts/Traveler/somewhere/another-folder/your_script.js'
ehcanadian
12/12/2018, 4:18 PMSuiteScripts/Traveler
. Templates
is a sub directory under the executing filejkabot
12/12/2018, 4:19 PMehcanadian
12/12/2018, 4:19 PMSuiteScripts/Traveler/my_suitelet.js
ehcanadian
12/12/2018, 4:20 PMsuitescripts/traveler/templates/my_template.xml
jkabot
12/12/2018, 4:21 PMehcanadian
12/12/2018, 4:21 PMjkabot
12/12/2018, 4:22 PMehcanadian
12/12/2018, 4:22 PMehcanadian
12/12/2018, 4:22 PMjkabot
12/12/2018, 4:22 PMscriptFile.path
will be 'SuiteScripts/Traveler/my_suitelet.js'
jkabot
12/12/2018, 4:22 PMscriptFolderPath
will be 'SuiteScripts/Traveler'
jkabot
12/12/2018, 4:23 PMscriptFolderPath + '/Templates/my_template.xml'
ehcanadian
12/12/2018, 4:23 PM../../
isn't finding the file if it's relative to the root of the cabinetjkabot
12/12/2018, 4:24 PMjkabot
12/12/2018, 4:25 PMehcanadian
12/12/2018, 4:25 PMehcanadian
12/12/2018, 4:25 PMjkabot
12/12/2018, 4:26 PMehcanadian
12/12/2018, 4:26 PMjkabot
12/12/2018, 4:26 PM