Link to home
Start Free TrialLog in
Avatar of jarrodprice
jarrodprice

asked on

Creating a dynamic file reference as a text field

I am using an email plug called mailit that can send emails within Filemaker with attachments.   I have created a script that grabs the file reference for the attachment from a global field.  The only way it works is if the file reference is a text field with the reference contained in quotes.

I wanted to change the file reference so that it works on any computer.  I tried changing the contents of the global field to Substitute(Quote(Get( DesktopPath) & "Inventory Update.xls");"/C";"C"), and it didnt work.

I am not sure what to do
Avatar of Member_2_908359
Member_2_908359
Flag of France image

do you mean to work on pc and mac or just on any PC?
also the plug-in probably need a windows or UNC path, not a fmaker one.
so you should get something like:
"C:\Documents and Settings\Utilisateur\Mes documents\Mes images\mire.png"
and  not
"C:/Documents and Settings/Utilisateur/Mes documents/Mes images/mire.png"
so swap / for \ and it shoud be ok.
Also not that dacons mailit has a browse option to select the file to attach.
Avatar of jarrodprice
jarrodprice

ASKER

I dont want to browse for it, this is an automated script.  This is a pc.  I dont understand your solution.

I want the file reference to be dynamic.  The point of the script is to first import an excel file to the desktop, then send it as an attachment for database backup.  The desktop folder is different on every computer, so I need the file reference to be a Get (desktoppath) calc.  A calc does not work for a file reference.
it does, but not directly, you must use a variable.
for instance:
set $file = get(...........)
then use $file as the fileref (you type it manually in the fileref dialog window).
That doesnt work.  I tried.
how do I reverse the /\ .

Substitute does not work to replace "/" with "\"
something else is wrong, I do this w/o any pb.
do you have an example from dacons for the attachement path syntax?
do you confirm that the plug-in must grab an external file of which the name is in a fm field?
If the global field it grabs from is a text file reference it works fine.  If it is a variable that is a text reference it is fine.

It only becomes a problem when I introduce a calculation into the mix, either within the global field it is referencing, or as part of the variable.

I know that get(desktoppath) creates the file reference as /C:/ rather then \, so it could be that.  I dont know.
Emai_SmtpAddAttachment(Emai_ImportFile(Globals::AttachmentPath);
"attachment"; Emai_GetFileName(Globals::AttachmentPath);
"once"; "" )

This it their example
the resulting path must use \ for sure.
and calc done on the fly should be ok, unless it is wrong
before using the Emai_SmtpAddAttachment function, use a custom dialog to display the same expression and check if it looks OK.
also quote function prevents get(desktoppath) from working. so remove that 1st
I am confused.  how do I switch the direction of the "\"'s

I tried evaluating the calc "get(desktop)path"

this is the result: "/C:/Documents and Settings/Administrator/Desktop/"

So how do I switch it around?

Substitute (get(desktoppath);"/";"\") does not work

I would guess this is the cause of the problem, so how do I switch them?

should be:
if you need quotes:
"\"" & right(substitute(get(desktoppath);"/" ; "\\" ); length(get(desktoppath))-1)& "\""
if you don't:
right(substitute(get(desktoppath);"/" ; "\\" ); length(get(desktoppath))-1)

ie, substitute the /, then skip the first character
still didnt work.

This should be easier.
ASKER CERTIFIED SOLUTION
Avatar of Member_2_908359
Member_2_908359
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what did you do finally?
The first step I imported the file into a container, then used their instructions for sending attachments from a container.

That way, I was able to use the Get (Desktoppath) when importing it into the container, without involving the plugin.

After that it worked fine