Hello Johan,
Well what I was trying do gain is to add a symple feature to the way files are opened as described in this forum.
If the file has been deleted or moved or the pathitem has been changed Windows doesn`t generate a failure but creates an empty file with the filename as you requested.
So what I was trying to do is before the copyfile action check if the file is valid if not an errormessage appears.
This was my code. filepath is a column in my table containing pathnames
if ( !filepath )
{
plugins.dialogs.showErrorDialog( 'Error', 'No Document attached', 'Continue')
return
}
if ( utils.stringMiddle(application.getOSName(), 1, 7) == "Windows")
{
if (plugins.file.jsfile.exists(filepath))
{
var VI_DocViewId = docviewid
plugins.file.copyFile(filepath, plugins.file.getDesktopFolder()+ '/DocView Saved Files/' + filename)
docviewid_docview.newRecord()
docviewid_docview.userdataid = globals.VI_UserDataId
docviewid_docview.docviewid = VI_DocViewId
}
else
{
plugins.dialogs.showErrorDialog( 'Error', 'The document was not found please check path "' + filepath + '".', 'Continue')
}
}
else
{
plugins.dialogs.showErrorDialog( 'Error', 'There was no association found on your system to open this file ' + utils.stringRight(filename, 3), 'Continue')
}
controller.relookup()
But the code “if (plugins.file.jsfile.exists(filepath))” returns an error “The undefined value has no properties.”
I believe it to be very simple but I don`t SEE it a code example providing the correct syntax will help.
btw I`ve tried to import your code into the solution and calculating the parentfolder but recieved the same error without the check it works just fine.
With kind regards Rene