Button to send mail and update activity

  • 0
  • 1
  • Question
  • Updated 1 month ago
  • In Progress
I almost have a button working.  What I want to do is open an email to the contact and create an activity saying the email has been sent.  So far I have this:-


var text URLONE = "MailTo:" & URLEncode([Email]);
var text URLTWO = URLRoot() & "db/" & [_DBID_ACTIVITIES]
& "?act=API_AddRecord&_fid_148=" & URLEncode([Record ID#])
& "&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxxx"
& "&_fid_7=Email Sent"
& "&_fid_142=" & ToFormattedText(Now(), "DDMMYYYYHHMMSS")
& "&_fid_165=" & "Email Sent"
& "&_fid_157=" & [Related Company];
var text URLTHREE = URLRoot() & "db/" & [_DBID_CONTACTS] & "?a=dr&rid=" & URLEncode([Record ID#]);
$URLONE
& "&rdr="& URLEncode($URLTWO)
& URLEncode("&rdr="& URLEncode($URLTHREE))

So $URLONE opens the email, $URLTWO creates the new activity and $URLTHREE keeps the current (Contacts)  page open with the new activity showing through a relationship link.

The email bit and the add record bit all work fine separately but I can't figure the code to get them working together.  The code like this just opens an email. 

I think it's do with the code around this bit but I could be wrong.

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

Any help gratefully received. 


Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb

Posted 1 month ago

  • 0
  • 1
Photo of Everett Patterson

Everett Patterson

  • 762 Points 500 badge 2x thumb
This link should help, essentially you need to change around the order of the URLs so the mailto: fire last aka $URLTHREE

https://community.quickbase.com/quickbase/topics/can-i-use-a-formula-url-button-to-create-an-email-u...

Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb
Thank you for replying, I tried this, the differences being "a=q&qid=" which I'm really not sure what it does and enclosing the formula variables in <>, all I get is a really long web string in the browser. 

var text URLONE = URLRoot() & "db/" & [_DBID_ACTIVITIES] 
& "?a=API_AddRecord&_fid_148=" & URLEncode ([Record ID#])
& "&_fid_157=" & [Related Company] 
& "&_fid_7=Email Sent"
& "&_fid_142=" & ToFormattedText(Now(), "DDMMYYYYHHMMSS")
& "&apptoken=cwfcy7gdzqrsyncqbi2bn4u4kr";

var text URLTWO = URLRoot() & "db/" & [_DBID_CONTACTS] & "?a=q&qid=1";

var text URLTHREE = "mailto:"& URLEncode([Email]);

"<a href=" &
$URLONE 
& "&rdr="& URLEncode($URLTWO) 
& URLEncode("&rdr="& URLEncode($URLTHREE))
& "></a>"

Do you know what is meant to happen with the variables enclosed in <a href anchor? 

: / 


Photo of Everett Patterson

Everett Patterson

  • 762 Points 500 badge 2x thumb
That was part of someone else's formula, I don't think you need that <a href anchor

var text URLONE = URLRoot() & "db/" & [_DBID_ACTIVITIES] 
& "?a=API_AddRecord&_fid_148=" & URLEncode ([Record ID#])
& "&_fid_157=" & [Related Company] 
& "&_fid_7=Email Sent"
& "&_fid_142=" & ToFormattedText(Now(), "DDMMYYYYHHMMSS")
& "&apptoken=cwfcy7gdzqrsyncqbi2bn4u4kr";

var text URLTWO = URLRoot() & "db/" & [_DBID_CONTACTS] & "?a=q&qid=1";

var text URLTHREE = "mailto:"& URLEncode([Email]);

$URLONE 
& "&rdr="& URLEncode($URLTWO) 
& URLEncode("&rdr="& URLEncode($URLTHREE))
Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb
Thank you again, It's almost there, I get the email opened and the activity updated but the QB takes me to a blank page with something like with the email included in the URL.  




Photo of Jack Fretwell

Jack Fretwell

  • 484 Points 250 badge 2x thumb
There's a bit of code in the link above which I don't fully understand.
"a=q&qid = 153"
To me this means "action = query and query ID = 153", but without knowing what qid=153 means I'm stuck, but this seems to be the bit that returns to the original page.  How do we store queries?