Forum Discussion

BradElmore's avatar
BradElmore
Qrew Assistant Captain
22 days ago

URL formula -API_RunImport

I would like to create a URL formula button -- that when clicked it will run a table to table import --- this is what I have created (did not work) 

var text URLONE = URLRoot() & "db/" & [Table ID] & "?act=API_RunImport&ID="&[TableImportID]&"";  

$URLONE

  • The advanced settings for your application there is a place to indicate whether or not you want to use application tokens. The extra level of security is up to you but for most of my clients I do not enable them unless there is some private healthcare data that they are concerned about. But if you do want to use application tokens then you need to create one and then use the syntax  

    var text URLONE = URLRoot() & "db/" & [Table ID]

    & "?act=API_RunImport&ID=" & [TableImportID]

    & "&apptoken=xxxxxxxxxxxxx"; 

     

     

  • Lee once you run a API call you need to learn the user on a page or a record or a report. Here is an example which will simply refresh the page that they user is on after the API call.    

     

    var text URLONE = URLRoot() & "db/" & [Table ID] & "?act=API_RunImport&ID=" & [TableImportID]; 

    var text RefreshPage =  URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

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

    • BradElmore's avatar
      BradElmore
      Qrew Assistant Captain

      Mark,

      It is asking me for a Application Token --- Can I use a User Taken? and where would I insert? Thank you

      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend

        The advanced settings for your application there is a place to indicate whether or not you want to use application tokens. The extra level of security is up to you but for most of my clients I do not enable them unless there is some private healthcare data that they are concerned about. But if you do want to use application tokens then you need to create one and then use the syntax  

        var text URLONE = URLRoot() & "db/" & [Table ID]

        & "?act=API_RunImport&ID=" & [TableImportID]

        & "&apptoken=xxxxxxxxxxxxx"; 

         

         

    • BradElmore's avatar
      BradElmore
      Qrew Assistant Captain

      Mark,

      If I want to have the color of the url button to change based on another field [field C]>0 -- would I need to create a Rich Text formula field? what would this look like? thank you

  • Yes, it would have to be a Fomula Ruch textfield.

    here ina low tech example.

     

    var text Words = "Click here to Toggle";

    var text Checkbox = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
    & "&_fid_12=" & not [checkbox];

    var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

    var text URL =
    $Checkbox
    & "&rdr=" & URLEncode($RefreshPage);

    If([checkbox]=false,
    "<a class=\"Vibrant Primary\"a href=" & $URL & ">" & $Words & "</a>", // blue
    "<a class=\"Vibrant \"a href=" & $URL & ">" & $Words & "</a>")  // gray

    // "<a class='Vibrant'>Vibrant</a>", // regular grey button
    // "<a class='Vibrant Alert'>Vibrant Alert</a>", // yellowish
    // "<a class='Vibrant Danger'>Vibrant Danger</a>", // red
    // "<a class='Vibrant Primary'>Vibrant Primary</a>", // blue
    // "<a class='Vibrant Snowy'>Vibrant Snowy</a>", // white
    // "<a class='Vibrant Success'>Vibrant Success</a>" // Blue again

    • BradElmore's avatar
      BradElmore
      Qrew Assistant Captain

       

      Mark, I'm using the Rich Text formula field below -- works great -- But I would like to Add a step -- that after running the "run-Import" -- I would like to change a check box field [field d]  - to True --- and then go to the "Refresh Page" --- is this possible?

      var text Words = "Consolidate";

      var text Checkbox = URLRoot() & "db/[tableId]?act=API_RunImport&ID=" & [TableImportID];

      var text RefreshPage =  URLRoot() & "db/[tableid]?a=q&qid=22" & Rurl();

      var text URL =
      $Checkbox
      & "&rdr=" & URLEncode($RefreshPage);

      var text button =
      $RefreshPage;

      • Gesco_QBAdminis's avatar
        Gesco_QBAdminis
        Qrew Trainee

        np,

        The generic syntax for running multiple steps in a URL is this, and keep in mind the last step needs to be to either refresh the page you are on,  or land the user on a record or a report or some page.

        $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))))))

         

        In you case we need three steps so we take 3 slices off the salami.

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

         

        so it would like this

        var text Import = URLRoot() & "db/" & [Table ID]

        & "?act=API_RunImport&ID=" & [TableImportID]

        & "&apptoken=xxxxxxxxxxxxx"; 

        var text CheckTheBox = URLRoot() & "db/" & dbid() & "?act=API_EditRecord&rid=" & [Record ID#]

        & "&apptoken=xxxxxxxxxxxxx"; 

        & "&_fid_99=1"; // 1 means true or checked

        var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

         

        $Import 
        & "&rdr=" & URLEncode($CheckTheBox)
        & URLEncode("&rdr=" & URLEncode($RefreshPage))

         

         

         

  • .... That previous post with the long answer was me, just signed in under the wrong user ID 

    • BradElmore's avatar
      BradElmore
      Qrew Assistant Captain

      Mark, that worked great! I ran into another issue with the formula field below --- This formula involves Two applications - [App A] and [App B] --- From [App A] in [Table B]  -- I created a Rich Formula Field (see below) -- My goal is to leverage a "table import" (API_RunImport&ID=38 (38 is my table import id in [App B] -- Import the records from [App A]/[Table B] into [App B]/[Table C] -- and return to the record form I press the "Import Records" button.

      var text Checkbox = I assume I enter the "[App_B_ID]/" vs "db/".

      var text RefreshPage = This is where I'm having an issue with my current formula -- the "db" is highlighted in yellow -- stating - A variable statement must end with a semi-colon

      Thank you again for your help.....

      Current Formula:

      var text Words = "Import Records";

      var text Checkbox = URLRoot() & "[App_B_ID]/[table_C_ID]?act=API_RunImport&ID=38; 

      var text RefreshPage =  URLRoot()&"db/tableid?a=dr&rid="&ToText([Record ID#])&"&dfid=10";

      var text URL =
      $Checkbox
      & "&rdr=" & URLEncode($RefreshPage);

      var text button =
      $RefreshPage;


      If([Total Records (Trace Table)]>0 and [# of Consolidated Trace records]>0,
      "<a class=\"Vibrant Primary\"a href=" & $URL & ">" & $Words & "</a>","")

      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend

        There are at least  issues.

        The first is that this line does not have a closing quote

        var text Checkbox = URLRoot() & "[App_B_ID]/[table_C_ID]?act=API_RunImport&ID=38; 

         

        Also I don't understand what you mean by this part below. The table ID is going to be the table for the target of he import - where the records are going into. 

        "[App_B_ID]/[table_C_ID]?