How to update a widget from a Shortcut?

I’m trying to create a very simple widget that shows some text.

This works just fine and the widget shows Hello

let input = "Hello"
let w = new ListWidget();

let text = w.addText(input);


but when I try to get the value from the Shortcut input, the widget never updates…

let input = args.shortcutParameter;
let w = new ListWidget();

let text = w.addText(input);


the value is reaching because if I add w.presentSmall() when I trigger the Shortcut I can actually see the update widget on the preview.

For reference this is the Shortcut

Am I missing something? Any idea what could be happening?

Im using iOS 17.0 and Scriptable 1.7.7

You would need to include a storage method for the text to be retrieved from in Scriptable. When the widget loads on Home Screen, it runs the code again and also at various intervals unless otherwise specified

Thanks for the hint, I save the text now to a file and it works.

In case someone finds this, this is how I do it.

let fm = FileManager.local();
let directory = fm.documentsDirectory();
let filePath = fm.joinPath(directory, "varianza.txt");

var content, w;
w = new ListWidget();

if (!fm.fileExists(filePath)) {
  fm.writeString(filePath, "New file created");
} else if (args.plainTexts.length > 0) {
  fm.writeString(filePath, args.plainTexts[0]);


I still need to open the app or call the refresh widget shortcut that opens the app, but better than nothing.

If someone know a way to trigger the refresh without opening the app let me know!

You’re welcome! Are you updating that file via a shortcut? The widget will refresh after the refresh time (variable by default) has elapsed and you are looking at the widget. This can be anywhere from 5-20 minutes from what I’ve seen.