Copy link to clipboard
Copied
Hello.
We have multiple operators and would like to add the name of the last operator for a document to a slug.
Currently we use text Variables to dynamically update filename and last modified date etc but i cannot see one for user.
It would be the name of the operator who last worked on it, so whomever is logged in.
InDesign 2020 on OSX.
Many thanks.
Hello wobblewoo!
it's a .jsx script not an Apple script. Copy the code into the text edit app and change the format to "Make Plain Text" and save it as a .jsx file.
Regards,
Mike
Copy link to clipboard
Copied
Hello wobblewoo!
This shold work for what your after......
1. Start off by creating a new text Variable;
Name: User
Type: Custom Text
Text: leave blank
2. Apply the "User" text Variable to the text frame for the slug.
3. On every users machine you'll need to install the Indesign Startup Script below.
#targetengine "session"
var eventListener = app.addEventListener("beforeSave", rememberLastUser, false);
function rememberLastUser(event) {
try {var doc = event.parent;
app.activeDocument.textVariables.item('User').variableOptions.contents = app.userName;} catch(err) {}
}
Each time the document is saved by a different user, the Text: in the "User" text Variable will be updated.
Regards,
Mike
Copy link to clipboard
Copied
Hello wobblewoo!
Note: After installing the Indesign Startup Script, InDesign will need to be quit out of and restarted.
Regards,
Mike
Copy link to clipboard
Copied
Thanks ever so Mike, however when compiling i get an error.
It's hilighting the eventListener on the second line of code and says:
Expected end of line, etc. but found identifier.
Can you help?
Copy link to clipboard
Copied
Hello wobblewoo!
Where are you trying to run the script from? It's a Startup Script and needs to be ran from the location below:
Also I forgot to mention each user needs to set their user name in InDesign, Go to the File menu ▸ user and enter User Name.
Regards,
Mike
Copy link to clipboard
Copied
Hello Mike, thanks for your help so far.
I've entered the username (File > User) into ID, no problems there.
When i cut and paste your code into Script Editor and saved as 'setUserScript.scpt' then placed here:
/Applications/Adobe InDesign 2020/Scripts/startup scripts/setUserScript.scpt
When i quit and then restart ID i get this error:
If i then try and compile the script from within Script Editor i get this:
Im on OS 10.15.7 and ID 15.0.1 if that matters.
Wx
Copy link to clipboard
Copied
Hello wobblewoo!
it's a .jsx script not an Apple script. Copy the code into the text edit app and change the format to "Make Plain Text" and save it as a .jsx file.
Regards,
Mike
Copy link to clipboard
Copied
Perfect. Thanking you.