Use the executor's GM permissions to grant the operating player ownership of a
prepared JournalEntry. First create the handout, copy its ID (not its UUID),
and replace YOUR_HANDOUT_ID in the script.
terminal.clear();
const handoutId = "YOUR_HANDOUT_ID";
if (handoutId === "YOUR_HANDOUT_ID") {
terminal.writeLine("Setup required: replace YOUR_HANDOUT_ID with a journal ID.");
} else {
const handout = game.journal.get(handoutId);
if (!handout) throw new Error("Handout unavailable");
if (await terminal.confirm("Retrieve the handout?")) {
await handout.update({
[`ownership.${program.controller.id}`]: CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER
});
terminal.writeLine("Handout retrieved. Open it from the Journal directory.");
audio.cue("success");
} else {
terminal.writeLine("Handout retained.");
}
}
Until configured, the Program prints a setup instruction and changes nothing.
After configuring a valid journal ID, Yes grants Owner permission to
program.controller.id and prints confirmation. No leaves ownership unchanged.
An unavailable journal produces a Program error.
Use program.controller to target the player: game.user is the GM running
the script. The ownership update persists and is not rolled back by Escape.
This example does not open a client-local Foundry window on the player's screen.
Uses terminal.confirm, program.controller, and audio.cue, plus Foundry's JournalEntry update API.