Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Add operator name to a text variable is a slug

Explorer ,
Sep 30, 2020 Sep 30, 2020

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.

TOPICS
How to , Scripting
727
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Oct 01, 2020 Oct 01, 2020

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

Translate
Advisor ,
Sep 30, 2020 Sep 30, 2020

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.pngexpand image

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

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 30, 2020 Sep 30, 2020

Hello wobblewoo!

 

Note: After installing the Indesign Startup Script, InDesign will need to be quit out of and restarted.

Regards,

Mike

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 01, 2020 Oct 01, 2020

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 01, 2020 Oct 01, 2020

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.pngexpand image

Regards,

Mike

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 01, 2020 Oct 01, 2020

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.pngexpand image

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

Screen-Shot-2020-10-01-at-15.31.14.jpgexpand image

Im on OS 10.15.7 and ID 15.0.1 if that matters.

Wx

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 01, 2020 Oct 01, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 01, 2020 Oct 01, 2020
LATEST

Perfect. Thanking you.

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