Dynamic file name if a specific named field exists or not.
I have created folder level scripts with corresponding buttons to create unique file names each time based on information in the file and the users who saved the file to a specified location.
Ocassionally there are files that will go to the same location, but the file itself does not have the named fields in my script and instead of created a second set of buttons and script for these types of files I would like the script to be able to identify if the file has the named field to use one naming convention and if not use another.
I can't seem to find the correct syntax or functions to do this. Below is a sample script with my line of thinking to complete this.
//Create Filename
function Name(){
if (doesObjectExists("Original Accession")==true){
var myFileName = this.getField("Original Accession").value + " " + getLoginName() +" " + myDateString();
}
else{
var myFileName = myIdString() + " " + getLoginName() +" " + myDateString();
}}
Later in the script i have a save as comand to a location with " +myFileName+".pdf". I do understand these need to be trusted functions and I have that set in place the bug I am ecountering is that the script doesn't understand myFileName. If I get rid of the if/else statement i recognizes one or the other of the naming conventions.
