Jump to content
Server Maintenance This Week. ×

Dupicating a Container and its contents


cknight

This topic is 6274 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have a document and image database and some of these documents are templates (for example an Omniform lease agreement template) I want to have the user of the solution to be able to click duplicate and it duplicates the record and the file referenced in the container. So far i have no problem developing a script that will do it ( iam using the Troi File plugin) BUT

I keep getting an error saying can't find the file to copy. Now i am using a GetAsText function on the computer and getting back 2 different file paths and i believe 1 is PC and 1 is Mac however my knowledge is limited on retrieving a filepath a determining whether its a PC or a Mac.

I have attached the sample FM file and the script i have to do it. Please tell me where i am going wrong

setField[gerrorcode]TrFile_CopyFile( "-Unused" ; testtroi::gSourceFilePath ; TrFile_SaveFileDialog( "-Unused" ; "Enter a filename if default isn't suitable" ; testtroi::__kp_id&testtroi::filetype ; testtroi::savefilepath ) )

The scripts are also in the actual Filemaker file

Oh yeah i am using referenced file not inserting the actual file in the container and i need it to work on PC and Mac

Untitled.fp7.zip

Link to comment
Share on other sites

It works fine if i create a field and just write the filepath in it and use that field as the filepath reference so i know the Troi File parts work.

The part i am not getting to work is the field i want to grab the path to a container. Right now its returning a Relative path and the Filemac path.

The problem is that i need to parse that text some how into a format that is an accurate file path. For example i have the following fields and calculation

gfilepath= global,text

document container=container field

and "gfilepath" has a calculation

GetAsText (document container)

it will return the following

File:/desktop/folder/doc

FileMac:/HD/User/Desktop/folder/doc

Problem is that inorder for troi to actually use it or anything actually it needs to be for the mac

:HD:User:Desktop:folder:doc

for the PC

c://Desktop/folder/doc

Why can't i pull a filepath that works. I know that i can use Get (platform) function to tell me Mac or PC so mb i can write an if statement to deal with that. I can only think that parsing the data might be my only solution which would suck and frankly i have no idea how to do it. Is there a way to get a filepath that will format correctly?

Link to comment
Share on other sites

SetVariable[$filepath;Value:Substitute ( GetValue ( testtroi::document container ; 2 ) ; ["filemac:/" ; ""];["/";":"] )]

the above seems to work fine as my add on parsing calc. I forgot i could designate which line of a carriage return so that made it easier

I am storing the file path in a Text global field

now my next step is to create a parse file path to save it at the right spot minus the document name. I can do this if when i add the files it takes the record id because then i can parse it out and since you select the file extension in a dropdown list i can make it automatically name the file. then i have to attache it to the new record which should be easy if i have the filepath and file name.

Link to comment
Share on other sites

Well here it is. I got it working. The only thing you need to do is select the document type before you import. It will then have you select the file name it with the ID# and the Document type and you select where you want to save it(i would set up a folder for it or script a first run script) Hit save and it will then ask you to select the file to insert and boom done.

The duplicate record will duplicate the record and then copy the file naming it for you and then you select it to insert.

What i want to do is be able to have the insert function happen without having a dialog to select the file i just made but i cant do a calculation on a Insert File Script otherwise it would be easy to take the filepath and add the id and Doc type and it would load automatically.

Any suggestions for this.( i can have a default file path for saving the files on the insert script but it would be cool so you dont see the dialog and it automatically does it but i cant figure out a way without the dialog.

Thanks for your help by the way

test2.fp7_2.zip

Link to comment
Share on other sites

I'm confused as to what you are trying to do, but if you are just after the file path, use

GetAsText ( Documents ). This doesn't require a plugin in v8.5.

If you have already tried this and it wasn't what you needed, then disregard this Reply.

HTH

Lee

Link to comment
Share on other sites

no lee i got the file path no problem and i am using it but what i am trying to do is insert a document into a container without having the "select file dialog" I want to do it using the filepath i stored in a field that way the user doesnt see anything happening when they duplicate a record it just makes a copy and inserts it into the container. Right now i have it working and it names the file for you but you still have to hit the save button in the dialog and then the dialog reappears and asks for the file to insert. Now with the Troi plug in I am doing something different for images and it works without a dialog because its creating a thumbnail and inserting it into the container but so far i cant automate that with a file.

Its easier to explain if you play with the file i posted. Just be sure to either name the doc type or select it before you use one of the buttons.

Edited by Guest
Link to comment
Share on other sites

Its easier to explain if you play with the file i posted. Just be sure to either name the doc type or select it before you use one of the buttons.

I looked at your file, but I do not use Plugins, so I can't help you here.

Sorry,

Lee

Link to comment
Share on other sites

This topic is 6274 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.