Reply
Visitor
Posts: 3
Registered: ‎04-03-2011
0

How to create records with applescript in X4

Dear all --

 

Can someone show me the correct syntax for creating new records in X4 via applescript?  I have a big workflow prepared which contains variables for the document title, URL, POSIX path to a PDF for attachment, etc. but I can't figure out how to get EndNote to create a new record, let alone how to pass these parameters to it...

 

Many thanks,

 

Andrew

Moderator
PTravis
Posts: 213
Registered: ‎03-28-2008
0

Re: How to create records with applescript in X4

[ Edited ]

The create record command takes an XML string and creates a record from it. I would recommend create one reference that has some data in the fields you plan to populate. Then highlight that reference and go to "File > Export" and save the file as an XML file. Then open the file in a text editor to note the names of the XML nodes used for the data you want in the records. Here is one example that creates a new record. Note that the record list in EndNote will not display this reference until you click on a group and then back to the list.

 

tell application "EndNote X4"
    
    set record_title to "Title of new record"
    set record_author to "Last, First"
    set record_year to "2011"
    set record_url to "http://www.endnote.com"
    set record_pdf to "file://localhost/Applications/EndNote X4/EndNoteX4MacHelp.pdf"
    
    set xml to "<records><record><ref-type name=\"Journal Article\">17</ref-type><contributors><authors><author>" & record_author & "</author></authors></contributors><titles><title>" & record_title & "</title></titles><dates><year>" & record_year & "</year></dates><urls><related-urls><url>" & record_url & "</url></related-urls><pdf-urls><url>" & record_pdf & "</url></pdf-urls></urls></record></records>"
    
    
    create record in first document with xml
    
end tell


Peter Travis

Thomson Reuters
Tel +1 800 336 4474
http://www.researchsoft.com
http://scientific.thomson.com

Better Decisions Faster
Thomson Reuters and its product names and acronyms used herein are trademarks, service marks, and registered trademarks used under license.
Moderator
PTravis
Posts: 213
Registered: ‎03-28-2008
0

Re: How to create records with applescript in X4

If you want to create all of the records at once, you could use Import instead.  The RSXML that Import takes allows for multiple records to be present in the XML unlike create record.

 

You can find the XML DTD in /Applications/EndNote X4/XML Support


Peter Travis

Thomson Reuters
Tel +1 800 336 4474
http://www.researchsoft.com
http://scientific.thomson.com

Better Decisions Faster
Thomson Reuters and its product names and acronyms used herein are trademarks, service marks, and registered trademarks used under license.
Visitor
Posts: 3
Registered: ‎04-03-2011
0

Re: How to create records with applescript in X4

Dear Peter --

 

Thanks so much for this.  One other question: is there a way to force EndNote to make a copy of the PDF in its own data folder, as it would do if i dragged a PDF to the new record window?

 

Andrew

Moderator
PTravis
Posts: 213
Registered: ‎03-28-2008
0

Re: How to create records with applescript in X4

Not using AppleScript, but you can have EndNote convert the PDFs afterwards.  After the records are created you can select those, or all references, and go to "References > File Attachments > Convert to Relative Links."  This will have EndNote copy the PDFs you linked to directly, i.e. the ones you created via AppleScript, into the PDF folder just as if you attached the PDF by dragging it to the record.


Peter Travis

Thomson Reuters
Tel +1 800 336 4474
http://www.researchsoft.com
http://scientific.thomson.com

Better Decisions Faster
Thomson Reuters and its product names and acronyms used herein are trademarks, service marks, and registered trademarks used under license.
Visitor
Posts: 3
Registered: ‎04-03-2011
0

Re: How to create records with applescript in X4

[ Edited ]

Dear Peter --


Thanks for your reply.  I'm still having some difficulty... Is there any documentation for the implementation of AppleScript in X4??

 

For example, in order to automate the "convert relative links" through UI Scripting, I need endnote to select the right record.  Looking through the dictionary, it seems that "show records in" accepts a list of records which, conveniently, is what the "find" statement returns.

 

That said, this script fails (shown in an attachment -- the forum won't let me post code??).  Nothing at all happens in my open EndNote document.

 

Any help would be greatly appreciated.

 

>AG

Moderator
PTravis
Posts: 213
Registered: ‎03-28-2008
0

Re: How to create records with applescript in X4

You may be able to use AppleScipt to execute "Edit > Select All" (Command+A) to highlight the list of references you have displayed.

 

But if you want all attachments in the library to be relative links you can select all of the references in the library and convert them to relative links once manually.


Peter Travis

Thomson Reuters
Tel +1 800 336 4474
http://www.researchsoft.com
http://scientific.thomson.com

Better Decisions Faster
Thomson Reuters and its product names and acronyms used herein are trademarks, service marks, and registered trademarks used under license.