Discussions

 View Only
Expand all | Collapse all

create records in a new table based on a report once a button is clicked

  • 1.  create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 11:51
    I have a report in table "A" with a date filter. Upon clicking a button, I want to create in table "B" as many records as the report has.
    Any suggestions?


  • 2.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 12:19
    There are different levels of automation possible.  The easiest to set up is to run your report and then use the More ...  button and select copy these records to another table.

    If that is not automated enough,  then there are other methods i can describe which require more setup.


  • 3.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 12:37
    I am looking for more automation. Final goal would be creating the records and then sending notifications to the assigned people. I was looking at using the Mr Daniel's  image onload technique but I'm struggling with the code. 


  • 4.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 12:49
    If the Filters on the report are standard, then the low tech way is to create a saved table to table import.     

    Then create a URL formula button to run the import and refresh the report.  The button can be located on the records that you want to copy and it does not matter which button you click (ie all records will have the same button) 

    The URL formula would be like

    var text URL = urlroot() & "db/" & [_DBID_TABLE_B] & "?act=API_RunImport&ID=10";

    "javascript:" &
    "$.get('" & 
    $URL & 
    "',function(){" &
    "location.reload(true);" &
    "});" 
    & "void(0);"


    That should run the import to create the records and refresh table A report.


  • 5.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 14:24
    This looks to be exactly what I need, but for some reason I can't get it to work... I created the Import and tested it. It works fine. I created the Formula URL button and placed it in the in the table I need to import from. Copied and pasted the formula from above and changed the table Id to the actual table name. Made sure that the report ID is 10, just like you predicted it... Not sure what else to look for...
    Here is the formula:

    var text URL = URLRoot() & "db/" & [_DBID_Field_S] & "?act=API_RunImport&ID=10";

    "javascript:" &
    "$.get('" & 
    $URL & 
    "',function(){" &
    "location.reload(true);" &
    "});" 
    & "void(0);


  • 6.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 14:39
    I forget about the application token.

    My guess is that  if you do this to test the button without the refresh, that it will fail.

    var text URL = URLRoot() & "db/" & [_DBID_Field_S] & "?act=API_RunImport&ID=10";

    $URL


    //"javascript:" &
    //"$.get('" & 
    //$URL & 
    //"',function(){" &
    //"location.reload(true);" &
    //"});" 
    //& "void(0);"


    So go to your setting for the application, and Advanced Properties and disable the need for application tokens, or else you will have to create an application token and change the first line to 

    var text URL = URLRoot() & "db/" & [_DBID_Field_S] & "?act=API_RunImport&ID=10"
    & "&apptoken= xxxxxxxxxx";

    Obviously paste in your app token code where the xxxxxx are.


  • 7.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 14:46
    That was it! Needles to say, you are awesome!!!
    Thank you! Maybe I get to buy you a beer next week at empower?


  • 8.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 14:50
    I will be there and if you are lucky there may be an open bar at the welcome evening so the beer you buy me could be cheap.  They will have an EMPOWER App to download on the phone for the Conference so you can look me up on it and connect.
    Mark


  • 9.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 14:55
    Awesome! Another thing to be looking forward to :)

    Thanks again!


  • 10.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 17:16
    I have a little follow up question. Is there a way for me to display a message window that will notify the user that  clicking the button will send an email to everyone on that report. If the user acknowledges, then send otherwise don't

    Hope I'm not asking too much
     


  • 11.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 17:20
    I have not tested but there was a recent post here
    https://community.quickbase.com/quickbase/topics/delete-a-record-without-going-into-grid-edit-or-goi...

    It contained this tip
    var text URL= URLRoot() & "db/" & Dbid() & "?act=API_DeleteRecord&rid=" & [Record ID#]
    & "&apptoken= xxxxxxx";

    "javascript: " &
    "if ( confirm('Are you sure you want to permanently delete this record ? ') == true ){ "&
    "$.get('" & 
    $URL & 
    "',function(){" &
    "location.reload(true);" &
    "});" 
    & "void(0);"&
    "}"


    So I assume if you just change the URL formula variable to the Run Import one, it will work.  Please post back and let me know.


  • 12.  RE: create records in a new table based on a report once a button is clicked

    Posted 05-17-2017 17:34
    It worked. Thank you!