Discussions

Expand all | Collapse all

Formula Text Button that opens in a new tab

  • 1.  Formula Text Button that opens in a new tab

    Posted 10-09-2017 21:00
    I have a formula text button that I need to open a child record in a new tab when clicked. Can someone please help me out?

    My formula is:

    var text rdr = URLRoot() & "db/" & [_DBID_ASSETS] & "?a=API_GenAddRecordForm"&
    "&_fid_112=" & URLEncode ("Part") &
    "&_fid_162=" & [Sales Order #] &
    "&_fid_338=" & URLEncode ([Record ID#]) &
    "&_fid_14=" & URLEncode ([Related Part Assignment]);

    var text url =

      URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
        "&rid=" & [Record ID#] &
        "&apptoken=biyf682cpfpeqfbfpv8pida6k3gy" &
           "&_fid_142=true"&
           "&_fid_101=" &Now();


    If(IsNull([Exchange Received])=false and [Line Type]="Part" and [Type]="Exchange",
    "<a class=\"Vibrant Primary\" href=\"javascript:" & "$.get('" & $url &
        "', function(){" & "window.location.href ='" & $rdr & "';" & "});" &  
        "void(0);\">Receive Exchange</a>",
    If([Exchange Received]=true and [Line Type]="Part" and [Type]="Exchange",
    "<a class=\"Vibrant Success\" href=\"javascript:" & "$.get('" & $url &
        "', function(){" & "location.reload();" & "});" &
        "void(0);\">Exchange Received</a>"
    ))


  • 2.  RE: Formula Text Button that opens in a new tab

    Posted 10-09-2017 21:57
    href='"&$URL&"' target='_blank'

    The blank target will use the browser default (which is usually a new tab)


  • 3.  RE: Formula Text Button that opens in a new tab

    Posted 10-10-2017 12:55
    This more or less made the button not work at all. Can you tell me if this is in the right spot?

    If(IsNull([Exchange Received])=false and [Line Type]="Part" and [Type]="Exchange",
    "<a class=\"Vibrant Primary\" href=\"javascript:" & "$.get('" & $url &
        "' target='_blank' , function(){" & "window.location.href ='" & $rdr & "';" & "});" &
        "void(0);\">Receive Exchange</a>",

    If([Exchange Received]=true and [Line Type]="Part" and [Type]="Exchange",
    "<a class=\"Vibrant Success\" href=\"javascript:" & "$.get('" & $url &
        "', function(){" & "location.reload();" & "});" &
        "void(0);\">Exchange Received</a>


  • 4.  RE: Formula Text Button that opens in a new tab

    Posted 10-10-2017 14:37
    Sorry for the confusion.

    Your current href is designed to refresh the page, correct?  (window.location .... void)

    you will replace all of that with the simple href="'& $URL &'" target='_blank'

    So it will preform your edit, but then open the rdr in a new tab.

    "<a class=\"Vibrant Primary\"
    href='" & $url & "&rdr=" & URLEncode($rdr) & "' target='_blank'
    >Receive Exchange</a>


  • 5.  RE: Formula Text Button that opens in a new tab

    Posted 10-10-2017 15:03
    This works! Is there a way to get it to also save the parent record? When I clicked it opened a new tab, but left the original page as is unsaved. 


  • 6.  RE: Formula Text Button that opens in a new tab

    Posted 10-10-2017 16:21
    For that you will want to use the 'linkaway' href call.  

    This is straight out of a template application:


    "<a  class='Vibrant Success' href='javascript:LinkAway(\"" & URLRoot() & "db/" & Dbid() & "?a=dbpage&pagename=success.html" & "\");' >Submit and redirect</a>"

    // This works because you have turned on the table's advance settings, "Save parent record automatically when a child record is created."

    yours will look like 
     href='javascript:LinkAway(\"" &$url & "&rdr=" & URLEncode($rdr) & "\");' target='_blank'


  • 7.  RE: Formula Text Button that opens in a new tab

    Posted 10-10-2017 16:24
    now that I'm thinking about it, that might not work.... 
    The javascipt and the target might fight each other.... 

    I've never had to do it this way and the syntax is probably wrong... 


  • 8.  RE: Formula Text Button that opens in a new tab

    Posted 10-10-2017 16:27
    Oh i see the issue with this now.  You are actually performing an edit of the record you are on.  So if you try to save, and edit and rdr, that might cause some issues. (especially with overriding data)

    What is the problem you are trying to solve for.  That might help with a more focused approach.


  • 9.  RE: Formula Text Button that opens in a new tab

    Posted 10-10-2017 16:37
    I'll tell the full story lol

    So when we sell some parts, we require the customer to send us back the bad part as an exchange. This button is in a report for the line items on a PO. So when pressed it will refresh that page (which is actually the PO) to show that the exchange was received, and simultaneously open a new tab that will allow us to enter that new part into inventory.

    The idea is to streamline the process a little bit. 

    Thanks! 


  • 10.  RE: Formula Text Button that opens in a new tab

    Posted 10-10-2017 21:38
    I think maybe I just need it to also refresh the original page. 


  • 11.  RE: Formula Text Button that opens in a new tab

    Posted 10-11-2017 02:59
    I think a good user experience would be to have the button, do the edit, and rdr to the new form all in the same window, BUT add the "nextURL" parameter.

    That way as soon as they click the "save & Close" it sends them back to the PO where they started.

    Sometimes opening new tabs throws people off because they forget to close them, and still don't know where they end up.


  • 12.  RE: Formula Text Button that opens in a new tab

    Posted 10-11-2017 12:26
    I completely understand your point. However, I was specifically asked to have it open in a new tab. The main user of this button may take a minute to be able to complete the information that opens in the new tab.