URL Button to Open New Window

  • 1
  • 1
  • Question
  • Updated 2 years ago
  • Answered
I have a formula URL button that when pressed, creates a child record and refreshes the record, however I need it to then open a new window. Here's what I have thus far:

            var text URL = URLRoot() & "db/XXX?act=API_AddRecord" & "&apptoken=XXX"& "&_fid_14="  & URLEncode ([Record ID#])
                         & "_&_fid_16=" & URLEncode ([Current User Name])
                         & "_&_fid_17=" & URLEncode ([Current User Email])
                         & "_&_fid_6=" & URLEncode (Now());

"javascript:" &
"$.get('" & 
$URL & 
"',() => location.reload(true));"


Going nuts here trying to figure this out for a client. Any help or input would be greatly appreciated and worthy of a Christmas card for life. If I'm unclear, just ask me and I'll answer any questions you have. Thanks!!! 
Photo of Todd

Todd

  • 150 Points 100 badge 2x thumb
  • frustrated

Posted 2 years ago

  • 1
  • 1
Can you clarify what is to Open in a new window, the child record?
Photo of Todd

Todd

  • 150 Points 100 badge 2x thumb
Thanks for the quick reply!! 
The child record is created and then the User should be automatically redirected to the refreshed parent record in a new window.
Photo of Matthew Neil

Matthew Neil

  • 31,698 Points 20k badge 2x thumb
Photo of Todd

Todd

  • 150 Points 100 badge 2x thumb
Opening target in new window will not work in this case because of the injected Java script. Thanks though!! 
This will create the child and if you click the box a box that Matthew indicated above, the child will display in a new window.

URLRoot() & "db/XXX?act=API_AddRecord" & "&apptoken=XXX"& "&_fid_14="  & URLEncode ([Record ID#])
 & "_&_fid_16=" & URLEncode ([Current User Name])
 & "_&_fid_17=" & URLEncode ([Current User Email])
 & "_&_fid_6=" & URLEncode (Now())
& "&disprec=1"
Photo of Todd

Todd

  • 150 Points 100 badge 2x thumb
Box is checked and I tried the code, however it didn't open in a new window
Are you trying to display the child in the new window or the parent.
Note that in my post above, it is just that code, not the javascript stuff. Don't include the javascript.
Photo of Todd

Todd

  • 150 Points 100 badge 2x thumb
Parent. The code I currently have Uses the URL variable to create the child record and uses the subsequent JS to refresh the parent afterward. So if it opens in a new window at any point,  at this point I'll be happy. lol
var text URLONE =
URLRoot() & "db/XXX?act=API_AddRecord" & "&apptoken=XXX"& "&_fid_14="  & URLEncode ([Record ID#])
 & "_&_fid_16=" & URLEncode ([Current User Name])
 & "_&_fid_17=" & URLEncode ([Current User Email])
 & "_&_fid_6=" & URLEncode (Now());


var text URLTWO = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#];

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


.... and set that  checkbox to open in a new window.
Photo of Todd

Todd

  • 150 Points 100 badge 2x thumb
Well, what can I say! You da man!! It worked! Can't tell you how thankful I am for you helping so quickly. I didn't know I could do a redirect after adding a record. I thought it had to be saved. 
Looking forward to getting some sleep now. Thanks again! 
The first night of Chanukah is December 12th.  I will watch my mail for my card.  

as for redirects, I have an app in the exchange called URL formuals for dummies.  You can do a lot of nested redirects.


$URLONE 
& "&rdr=" & URLEncode($URLTWO)
& URLEncode("&rdr=" & URLEncode($URLTHREE))
& URLEncode(URLEncode("&rdr=" & URLEncode($URLFOUR)))
& URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLFIVE))))
& URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSIX)))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSEVEN))))))

The very last one needs to display a record or report so the user does not see the XML success message, which is not user friendly. 
Photo of Todd

Todd

  • 150 Points 100 badge 2x thumb
Address?
:)
mark.shnier@gmail.com

It can be electronic.  Or just an email.