Skip to main content
Participant
November 1, 2022
Answered

UXP (IDJS) LocalStorage usage

  • November 1, 2022
  • 2 replies
  • 822 views

Hi everyone,

 

I'm tinkering around with the new UXP javascript in InDesign and would like to store a value in LocalStorage. But I can't seem to get a value saved to storage.

 

Here is my code:

 

main();

function main() {
    console.log('Main function entered.');

    window.localStorage.setItem('myKey', 'myValue');

    console.log(window.localStorage.getItem('myKey'));
}

Code is in /Users/<my-username>/Library/Preferences/Adobe InDesign/Version 18.0/de_DE/Scripts/Scripts Panel/my-scripts/localStorage.idjs

 

I'm tailing the log files in Terminal from /Users/<my-username>/Library/Caches/UXPLogs to see the console.log() output. The first log entry shows Main function entered. but the second one is null.

 

Am I missing something?

 

My InDesign version is 18.0 on OSX 12.6.1

This topic has been closed for replies.
Correct answer erinferinferinf

@amandahuang says:

 

scripts don’t have access to window.localStorage

 

UXP plugins for InDesign are expected next year.

2 replies

erinferinferinf
Adobe Employee
erinferinferinfCorrect answer
Adobe Employee
November 4, 2022

@amandahuang says:

 

scripts don’t have access to window.localStorage

 

UXP plugins for InDesign are expected next year.

Community Manager
November 4, 2022

As Erin said, scripts don't have access to persistent storage options including `window.localStorage`. This is because each script has its own execution context that is destroyed when the script is finished executing. Once we roll out UXP plugins for InDesign, that will be available.

erinferinferinf
Adobe Employee
Adobe Employee
November 2, 2022

Hi Daniel,

 

Something is buggy about the forum script tag "UXP Scripting" at the moment, but I did put this in front of the InDesign team. You might want to also search https://forums.creativeclouddeveloper.com/ for local storage...