Forum Discussion

MindaMay's avatar
MindaMay
Qrew Cadet
5 years ago

Button to Add Child Record, Save it, Display it, Reload, then Edit mode

I have a button that adds an Estimate to an Opportunity. The button Adds the child record, Saves it, and Displays it. An automation runs in the background that adds child records to the Estimate. Ideally I want my button to do two more things. Refresh the new Estimate and display it in Edit mode.

Here's what I have so far. Any ideas?

//This uses the Quick Base API to Add a Related Estimate, Save it, and then display it.
URLRoot() & 
"db/" & [_DBID_ESTIMATES] & 
"?a=API_AddRecord&_fid_6=" & 
URLEncode ([Record ID#]) &
"&apptoken=mytokenishere" &
"&disprec=1"

4 Replies

  • JackFretwell's avatar
    JackFretwell
    Qrew Assistant Captain
    You may need to look into writing a Java script using Dan Diebolts iol technique.  (This is very useful)
    https://community.quickbase.com/quickbase/topics/how-do-i-setup-the-image-onload-technique-iol
    https://community.quickbase.com/quickbase/people/dandiebolt

    Dan has many Java scripts which are available to use but please ask Dan and give credit.

    1) Create the new record with AddRecord API.
    2) This can give you an XML result with the Record ID# of the new record.

    The XML reply will look something like:
    <qdbapi>
       <action>API_AddRecord</action>
       <errcode>0</errcode>
       <errtext>No error</errtext>
       <udata>mydata</udata>
       <rid>21</rid>
       <update_id>1206177014451</update_id>
    </qdbapi>

    3) Grab the Record ID via a Java script (Something like).
    ...
    ...then(function(xml){
    $("record", xml).each(function() {
    myvariable = $("rid", xml).text()
    ...

    4) With the record ID you can select, refresh and open in Edit mode.

    This is something I know I have to do.

    There may be other methods to do this, this is what I'm aware of at the moment and what I'll be working to.
  • Hey, I ended up solving this with a Rich Text field that displays a friendly message and a form rule. The message only shows up when the record is newly added and needs to be refreshed to show the line items.

    Here's the code of the Rich Text field:

    "<span style='background-color: #DCECD1; padding:7px; border:1px; border-color: #4E9E19'><img src='theCheckMarkStoredinmyImageTable.png' width='14'> &nbsp;&nbsp;<b>Estimate added and saved</b>. Click <b>Edit</b> or refresh the page to see line items.</span>"

    And here's what it looks like only with a green background to match what you see when a record is saved. For some reason the border-color and border isn't showing but it still looks good and works.

       Estimate added and saved. Click Edit or refresh the page to see line items.
  • Another technique is to put the child table report link in a tab. By the time the user clicks the tab, the automation will have run and the children will be there.
  • When Quick Base demo'ed Automations at Last year's EMPOWER, when they were very very new and before they changed Quick Base to only populate tabs when they come into focus,  they used that trick on the main stage so as not to have the untidiness of having to refresh the page.  They forced their demo app to have that new feature (populate embedded reports only when they come into focus) ahead of the rest of us.

    So they demoed Automations, but sort of gave a sneak preview for delayed loading of embedded reports.