Highlighted

Add operator name to a text variable is a slug

New Here ,
Sep 30, 2020

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

TOPICS
How to, Scripting

Views

131

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Add operator name to a text variable is a slug

New Here ,
Sep 30, 2020

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

TOPICS
How to, Scripting

Views

132

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 30, 2020 0
Engaged ,
Sep 30, 2020

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

Screen Shot 2020-09-30 at 5.09.35 PM.png

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.

  • ‎⁨Startup location: Mac⁩ ▸ ⁨Applications⁩ ▸ ⁨Adobe InDesign 2020⁩ ▸ ⁨Scripts⁩ ▸ ⁨startup scripts⁩

 

 

#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

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 30, 2020 1
Engaged ,
Sep 30, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 30, 2020 0
New Here ,
Oct 01, 2020

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 01, 2020 0
Engaged ,
Oct 01, 2020

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:

  • ‎⁨Startup Script location: Mac⁩ ▸ ⁨Applications⁩ ▸ ⁨Adobe InDesign 2020⁩ ▸ ⁨Scripts⁩ ▸ ⁨startup scripts⁩

 

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.

Screen Shot 2020-10-01 at 10.02.57 AM.png

Regards,

Mike

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 01, 2020 0
New Here ,
Oct 01, 2020

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:

Screen Shot 2020-10-01 at 15.26.42.png

If i then try and compile the script from within Script Editor i get this:

Screen-Shot-2020-10-01-at-15.31.14.jpg

Im on OS 10.15.7 and ID 15.0.1 if that matters.

Wx

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 01, 2020 0
Engaged ,
Oct 01, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 01, 2020 1
New Here ,
Oct 01, 2020

Copy link to clipboard

Copied

Perfect. Thanking you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 01, 2020 0