Forum Discussion

JackFretwell's avatar
JackFretwell
Qrew Assistant Captain
7 years ago

Button to send mail and update activity

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. 


  • JackFretwell's avatar
    JackFretwell
    Qrew Assistant Captain
    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? 

    : / 


    • EverettPatterso's avatar
      EverettPatterso
      Qrew Captain
      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))
    • JackFretwell's avatar
      JackFretwell
      Qrew Assistant Captain
      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.  




    • JackFretwell's avatar
      JackFretwell
      Qrew Assistant Captain
      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?  
      • NickCharalambou's avatar
        NickCharalambou
        Qrew Cadet
        Did you get this to work? I have the same issue and cannot make it work.

        Nick

        ------------------------------
        Nick Nick
        ------------------------------