Discussions

Expand all | Collapse all

Button in Embedded Report

  • 1.  Button in Embedded Report

    Posted 10 days ago
    Is it possible to have a functioning button in an embedded report? One per row/record.

    Due to circumstances, I have an embedded report that facilitates mass input of data.

    But for things to work, I need a button for each row/record that will allow me to generate the record prior to inputting the data.

    It is the only workaround that I have conceived that will still allow me to keep intact my process flow.


    Thoughts?


    ------------------------------
    Andrew
    andrew.fry25@gmail.com
    ------------------------------


  • 2.  RE: Button in Embedded Report

    Posted 10 days ago
    You can definitely have a formula URL button on an embedded report.  But it's Still unclear from your post as to what the button is supposed to do.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------



  • 3.  RE: Button in Embedded Report

    Posted 10 days ago
    Thanks for the response Mark.

    So I have the Assignments table, and included a Formula URL as a field.
    I gave the field some code, had it appear as a button, and had the button colored.
    The button shows up in the Report of that table, as well as in the form of that table.

    However, when I have the report embedded in the form of another table, the column for the button field is present, but no button is visible.
    When I click on the cell for the button, nothing happens, and when I double click it states:

    The field is a formula field and is not editable in the embedded report.

    That leads me to believe that I can't have the button be usable in an embedded report.

    ---------------------------------------------

    As I was typing the above, I had a thought of how I could possibly achieve what I need.
    I wanted to have a button in each row of the embedded report. So that when I click that button it generates a new record for the row and allows me to input the associated data. I need to have the record generated before I input data into the record because I have to bring down some data from grandparents and parents. I have a field that is conditional based upon that data from the Grandparent/Parent.

    However, after giving it some thought, I think that the better way to do it would be to have a single button, like the "Add Record" button, in the form.
    But it would need to be customized to do what I need/want.

    Normally, the add record button will take me to the child record form where I can input the data, then save/close. It then takes me back to the parent form.
    I believe that the customized button would need to generate a child record, save/close, and take me back to the parent record immediately. I shouldn't even see the child record form.

    I think that this would give me the same result.

    Thoughts?

    ------------------------------
    Andrew
    andrew.fry25@gmail.com
    ------------------------------



  • 4.  RE: Button in Embedded Report

    Posted 7 days ago
    Andrew,

    Yes, it's possible to have a button within an embedded report and it would behave the way you want it to, but from your description it appears that you've turned on the "editable" setting for your report. With that in place, the button won't be accessible unfortunately.

    You found the other option I was going to suggest, and that's to place a button to create a child record on the parent form and this should behave the way you want it to. It seems like you're comfortable with setting this up already, but if you want a useful working example, I covered an API_EditRecord version (instead of API_AddRecord like you would need) during our Empower user conference in June. For a recording of the session, please go here.

    Eric

    ------------------------------
    Eric Mohlman
    ------------------------------



  • 5.  RE: Button in Embedded Report

    Posted 7 days ago
    Edited by Andrew Fry 7 days ago
    Eric,

    Thanks for the response. I am still new to quickbase, so trying to learn as much as I can. Any response helps.
    So I think my solution is a few parts, and I want to be able to combine them all into one button, if possible.
    I believe I have some of it, but am still struggling with the other parts.

    Currently the user opens a new Work Order fills in any needed data, clicks the "Add Job" button, the Work Order record is saved and the user is taken to the Job form. On the job form, the user inputs information for the job, and then in the assignments editable embedded report, enters additional information. They click the Save & Close button, the Job and related assignments are saved, and the user is taken back to the parent work order in edit mode to continue if needed. That process flow is smooth and what I would like to maintain, if possible, or at least as close to that as is possible.

    Issue:
    I need to bring down a related client from the parent record (Work Orders) to the child record (Jobs). That related client also has to be brought down to the grandchild record (Assignments). All this is to allow a Contacts list in the grandchild record to be conditional based upon the related client, and show only the related contacts to that related client. The grandchild is an editable embedded report  in the child form. The Child and Grandchild being Parent and Child.

    In order to have the related client flow down from the child to the grandchild, the child record has to be generated/saved first. Then for the related client to populate in the grandchild record so that the conditional contacts list functions, the grandchild record also has to be generated/saved first too.

    It breaks the process flow to require a user to enter some data, save, go back and edit, enter some more data, save, go back and edit, and then save again.

    Solution:
    I think that I have a solution, but I am only part way there.

    My Jobs form didn't incorporate the default "Add Assignment" button because the embedded report is editable.
    However, I think that I will add it and edit the code in it.

    When clicked, I need it to do the following:

    • Generate/Save the Job form
      • This will allow the related client to be brought down to the Job, and in turn eventually to the assignment
    • Generate/save a new assignment related to the Job
      • This will allow the related client to be brought down to the assignment, and in turn allow the conditional contacts list to function properly.
    • Take me back to the Job form in edit mode so that I can continue making any changes as needed.

    One caveat is that in doing this, I need to ensure that I maintain the return path back to the Parent (Work Order) record, so that when I click on Save & Close in the Job form, it saves and then takes me back to the work order in edit mode.

    The code I have thus far is the following:

    URLRoot() & "db/" & [_DBID_ASSIGNMENTS] & "?act=API_AddRecord"
    & "&_fid_6=" & URLEncode ([Job ID#])
    & "&rdr=" & Dbid()& URLEncode("?a=er&rid="&[Job ID#])

    This is in the Job form, generates a new Assignment and keeps me in the Job form in edit mode.

    What it is lacking is saving the Job first (then doing the above), as well as maintaining the return path to the Parent record in edit mode.

    I am currently reading through the API guide to get a better understanding of the calls and syntax, as well as messing around with the "URL Formula Buttons for Dummies" app by Mark Shnier, and also wrapping my head around the "Magic Buttons - Having Fun with Formula URLs" app by Kirk Trachy.

    If you have any suggestions, thoughts, input, ideas, etc., it is very welcomed!!

    P.S. I will have to check out those Empower sessions you recommended.

    Too much to absorb, not enough time!! hahaha lol

    ------------------------------
    Andrew
    andrew.fry25@gmail.com
    ------------------------------



  • 6.  RE: Button in Embedded Report

    Posted 7 days ago
    Edited by Evan Westbrook 7 days ago
    Andrew,

    It sounds like your tables look something like the following. Please let us know if that is not correct.

    ERD of tables
    There are a couple of ways to approach a solution from here:
    1. Code button as described
    2. Think up another way to do it

    Based on the situation you describe, you might want to check out option Number 2 with a QuickBase Automation
    Option 2: QuickBase Automation
    Automations can fire off of a "trigger" field. For your situation, you might do something like:
    1. Create a field on the "grandparent" table, "Work Order," called [Create Trigger]
    2. Make your "Edit Record" button change the "Work Order" record on which it was clicked to "true"
    3. Automation fires when record on "Work Order" changes and [Create Trigger] = "true"
    4. Automation makes child record on "Jobs" and grandchild record on "Assignment" passing down the Record ID# of the records created
    5. Automation changes [Create Trigger] = "false"

    Option 1: Code button
    Keeping in mind this seems a little complicated for the situation you describe and embedded JavaScript is not officially supported by QuickBase, you could do something like the following:

    // Define API Call for Adding Record
    var text url = URLRoot() & "db/" & [_DBID_WORK_ORDER] & "?act=API_AddRecord" & "&_fid_6=" & URLEncode ([Job ID#]));// Define a Callback to run when API call completes
    var text callback = "function(xml){destrid=$(xml).find('rid').text();newpage='" & URLRoot() & "db/" & [_DBID_JOB] & "?a=dr&rid='+destrid;window.location.href=newpage";
    
    // Define Script to execute when button is clicked
    var text script = "javascript:$.get('" & $url & "'," & $callback  & "});void(0)";
    
    $script;


    The code above executes an API call, parses the the data QuickBase returns on success, extracts a value, and redirects a user to the a different page. In theory, you could make a callback that creates the child and grandchild record. This method has been hit and miss with me.











    ------------------------------
    Evan Westbrook
    PRIME Developer
    Harder Mechanical Contractors Inc.
    Portland OR
    ------------------------------



  • 7.  RE: Button in Embedded Report

    Posted 2 days ago
    Edited by Andrew Fry 2 days ago
    Evan,

    Thanks for the very detailed response. I very much appreciate it. Sorry for the delayed follow-up on my end. I have been on vacation for the past few days.

    Yes, that is how I have the tables set up.

    I understand how your Option #2 works, in theory. However, for it to work as you suggest, wouldn't the Work Order Record ID would first need to be generated? Meaning the work order would need to be saved so that it had an associated Record ID# first, before the automation can run, right?

    With how the process flow works currently, generating the Work Order first, then manually going back in to edit it​ to click a button breaks the flow somewhat.

    Also, if we set it up to generate a new child and grandchild record each time it was edited, we would have more children records than really are needed. The Grandparent record will be edited multiple times throughout the process, so we don't want to generate a child/grandchild record each time.

    However, after reading through your suggestion, I had a thought, but am not sure if it will work.

    Ideally, from within the work order form, if I click on "Add new Job", the code in the button would save the Work Order (thus generating a Record ID#), and then also generate a new job record, taking me back to the Work Order form in edit mode.
    By doing it this way, I wouldn't need to worry about saving the return pat back to the Work Order from the Jobs form.

    I have the code to save and keep working. It is currently in a Formula Rich Text button:

    "<div class='Vibrant Success' onclick=$('#footerSaveAndKeepWorkingMenuOption').click();>Save and Keep Working</div>"​

    I also have the code to generate a new Job, take me back to the Work Order in edit mode. It is currently in a Formula URL button:
    URLRoot() & "db/" & [_DBID_JOBS] & "?act=API_AddRecord"
    & "&_fid_16=" & URLEncode ([Work Order ID#])
    & "&rdr=" & Dbid()& URLEncode("?a=er&rid="&[Work Order ID#])​​

    I was hoping to combine them both into a single button, so that it first runs the "Save & Keep working" and then generates the Job.

    I tried the following:

    "<div class='Vibrant Success' onclick=$('#footerSaveAndKeepWorkingMenuOption').click();>Save and Keep Working</div>"
    & URLRoot() & "db/" & [_DBID_JOBS] & "?act=API_AddRecord"
    & "&_fid_16=" & URLEncode ([Work Order ID#])
    & "&rdr=" & Dbid()& URLEncode("?a=er&rid="&[Work Order ID#])​​

    However, when I went to combine them, I get an error message. I am sure it is due to my lack of experience in syntax and combining different coding types.

    Any thoughts? Do you think something similar to the above would work? I am trying to make it as simple as possible.

    ------------------------------
    Andrew
    andrew.fry25@gmail.com
    ------------------------------



  • 8.  RE: Button in Embedded Report

    Posted yesterday
    Edited by Evan Westbrook yesterday
    Andrew,

    Thanks for clarifying your use case!

    A revised version of Option 2 might work:
    You can set up Automations to fire on different conditions including "only add records" and "add or modify records". Additionally, any automation will fire after the record is created, so you won't have to worry about [Record ID#] not yet existing. With that in mind, maybe you could do something like the following:
    1. Automation 1
      1. When "Work Order" Record is added, then "do stuff." No need for a button there unless you have use cases where child records are not needed.
    2. Automation 2
      1. When "Work Order" Record is added or modified and conditions are met, then "do stuff."
    This way you can only add child records on set up and only do updates on other conditions if needed.

    Regarding the button:
    Without getting too into the weeds, the code in your last message generates an error due to syntax. Formula Rich Text fields allow you to inject HTML code into native QuickBase, but you have to write all of the code. In Formula URL buttons, QuickBase wraps a URL link in HTML code for you. That's why URL based API Calls work in Formula URLs, but you have to wrap additional code around the URL based API call for it to work in Rich Text.

    What you describe can be done, but it's a little advanced. If you want to go down that route, I would recommend researching how to embed JavaScript scripts in HTML code using jQuery (that's what the "$" indicates) and using callback functions in jQuery's "onClick()" function.

    ------------------------------
    Evan Westbrook
    PRIME Developer
    Harder Mechanical Contractors Inc.
    Portland OR
    ------------------------------