Logging a URL formula

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

Hi :smile:

I have created a URL Formula field in a form which sends emails (URLEncode).

It's neat, it's a cute little button, and it opens into my Outlook.

In the same form / table, I have also created a text/multi-line field for the purpose of logging entries/activities.

How can I have an entry automatically be created in that multi-line box whenever someone uses those URL sending email buttons?  I would like to know date/time and the person who sent the email.

Thanks! :smile:

Photo of Philippe - ZEROFAIL

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
var text URLONE = urlroot() & "db" & dbid() & ?"act=API_EditRecord&rid=" & [record id#]

& "&_fid_xx=" & URLEncode("email sent")

var text URLTWO = ... put your mail to filed here.

$URLONE

& "&rdr=" & URLEncode($URLTWO)



So if you set up that field xx (change the xx f=to the field ID of a new text field set to Log changes) to log changes, the it will log the email was sent (and by who and when) and then pop open Outlook.
Sorry-- Where do I put this code?  As part of the code I have already written / in the URL Formula field alongside the rest of it?

Here's what I have thus far:


"MailTo:"&([Customer - Email])
&"?cc="&([Customer - Salesperson])
&"&subject="&([Customer Name])&" : New Service"
&"&body="&"Ref.: Contract n° "&([Project - Contract ID])&"  ("&([Project Name])&" --- "&([Related Location2 - Location])&")"
&"%0A%0A"
&"Good day,"
&"%0A"
&"%0A"&"blablablablabla."
&"%0A"
&"%0A"&"MoreNonsenseBlablablabla."
&"%0A"
&"%0A"&"SomeMoreBlabla."
&"%0A"
&"%0A"&"Regards,"
&"%0A%0A"

The text multiline field ID is 18 in this table.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
Don't put you code, just put your existing field that already works

var text URLONE = urlroot() & "db" & dbid() & ?"act=API_EditRecord&rid=" & [record id#]

& "&_fid_xx=" & URLEncode("email sent")

var text URLTWO = [my mailto URL field goes here]

$URLONE

& "&rdr=" & URLEncode($URLTWO)
Hi again :smile:

So --- I am not a programmer.  I am just following your instructions.  And, unfortunately, those do not work, I get an error message.  Following your instructions, I have this right now (which causes an error):


var text URLONE = urlroot() & "db" & dbid() & ?"act=API_EditRecord&rid=" & [record id#]
& "&_fid_18=" & URLEncode("email sent")
var text URLTWO=
["MailTo:"&([Customer - Email])
&"?cc="&([Customer - Salesperson])
&"&subject="&([Customer Name])&" : New Service"
&"&body="&"Ref.: Contract n° "&([Project - Contract ID])&"  ("&([Project Name])&" --- "&([Related Location2 - Location])&")"
&"%0A%0A"
&"Good day,"
&"%0A"
&"%0A"&"blablablablabla."
&"%0A"
&"%0A"&"MoreNonsenseBlablablabla."
&"%0A"
&"%0A"&"SomeMoreBlabla."
&"%0A"
&"%0A"&"Regards,"
&"%0A%0A"]
$URLONE
& "&rdr=" & URLEncode($URLTWO)


What am I doing wrong?

Thanks :smile:
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
You said that you had a field working which popped up the mailto and opened up Outlook.  Can you tell me the name of that field?
I named this one "First Email - English" (ID:21)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
var text URLONE = urlroot() & "db" & dbid() & ?"act=API_EditRecord&rid=" & [record id#]

& "&_fid_xx=" & URLEncode("email sent")

var text URLTWO = [First Email - English]

$URLONE

& "&rdr=" & URLEncode($URLTWO)
Thanks.  And --- where does this code go?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
This is  the code for a URL formula field. which you might want to call "First Email - English & log as emailed".

I would also change the code to this below

var text URLONE = urlroot() & "db" & dbid() & ?"act=API_EditRecord&rid=" & [record id#]

& "&_fid_xx=" & URLEncode("First Email - English sent")

var text URLTWO = [First Email - English]

$URLONE

& "&rdr=" & URLEncode($URLTWO)
I don't understand.  
I already have a URL formula field, with the code I stated above.
And it already works.

Now I want for a log to be taken every time that code is pressed.

And I understand that you are telling me to replace the code I have (and which works) for a different code.

I apologise, but I do not understand what you are saying.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
Keep you old field exactly as it is.
Make a new field which will first log that the email was sent and then execute your old button.

When you have the new button working, then take the old button off the form.  The old button does one thing.  The new button does two things.
Ah!  That, I understand.

Now, I tried your code in a new URL formula field, and I am getting an error:


Formula syntax error

Expected a valid expression after the "&"

// Everything is italic after the 1st "&" on the 2nd line


var text URLONE = urlroot() & "db" & dbid() &   ?"act=API_EditRecord&rid=" & [record id#]
& "&_fid_18=" & URLEncode("First Email - English sent")
var text URLTWO = [First Email - English]
$URLONE
& "&rdr=" & URLEncode($URLTWO)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
Try this.  i was missing the semi colons ; to end each formula variable and some other errors.


var text URLONE = urlroot() & "db" & dbid() &   "?act=API_EditRecord&rid=" & [record id#]
& "&_fid_18=" & URLEncode("First Email - English sent");

var text URLTWO = [First Email - English];

$URLONE
& "&rdr=" & URLEncode($URLTWO)
Another error:

*I get a different webpage with a little guy stating:*

-------------------------------------------------------
There's nothing there...

We can't understand the URL you specified.
If you think the URL is correct, try refreshing this page.

For more information, check out the service page.
Contact support if you need help with this problem.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
Try this one.  I was missing the / after the db

var text URLONE = urlroot() & "db/" & dbid() &   "?act=API_EditRecord&rid=" & [record id#]
& "&_fid_18=" & URLEncode("First Email - English sent");

var text URLTWO = [First Email - English];

$URLONE
& "&rdr=" & URLEncode($URLTWO)
Another error, on a different webpage (mostly blank)

--------------------------
This XML file does not appear to have any style information associated with it. The document tree is shown below.

<qdbapi>
<action>API_EditRecord</action>
<errcode>24</errcode>
<errtext>Invalid Application Token</errtext>
<errdetail>An Application Token must be supplied.</errdetail>
</qdbapi>
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
... please go to Settings for the application and then Advanced Settings and turn off Application Tokens. (uncheck)
Require Application Tokens
Unchecked, saved.
Retried.
Another error:

-----------------------
This XML file does not appear to have any style information associated with it. The document tree is shown below.

<qdbapi>
<action>API_EditRecord</action>
<errcode>30</errcode>
<errtext>No such record</errtext>
<errdetail>Missing "rid" parameter.</errdetail>
</qdbapi>
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
The record has to be saved before this will work.  Only show the button in edit or view mode mode.  What mode are you in .. are you in Add mode?
Yes, I was using the form to gather the required data I need to create the email:

[Customer - Email]
[Customer - Salesperson]
[Customer Name]
[Project - Contract ID]
[Project Name]
[Related Location2 - Location]

And then I was pressing my button :smile:
And it worked :smile:
In "Add" mode, without the need to save it.  Just a cool little form to send customized emails.

And I just wanted to log that :smile:

So you're saying I need to create an actual record (which I don't really need) before logging that function?
Once it is saved, it works though :smile:
Once I click on your button, the form turns blank.
Can we add a refresh of sorts afterwards?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 64,302 Points 50k badge 2x thumb
If you wanted the log that the email was sent, where did you want it logged.  It could be logged to another table if that was what you had in mind.

as for the blank form, try checked the box on the url formula that says to open in a new window.
Thanks!
It looks like it doesn't log in view mode.  Thoughts?