Custom HTML Page in quickbase

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • In Progress
I have two tables, Table A(Parent) and B(Child), Where A is related to B (one to Many). When user goes into Table A and selects No, it directs the user to this custom HTML page. And on this page i need a button that upon clicking directs the user to create a child record for that Parent. I m not able to figure out the code for that button.  
Photo of JW

JW

  • 140 Points 100 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
So basically how should it be like

Create a text field of options yes and no

if($("#_fid_6").val() === "Yes"){
location.href = "http://www.google.com";
}

Instead of google paste the URI of the page (Home-Settings-Pages-Click on view icon of the corresponding page )

paste the URL instead of google.com

in that page
 
have the below sample code replace whatever URI you want  on the action tag

<html>
<form action="https://www.google.com">;
    <input type="submit" value="Go to Google" />
</form>
</html>


This is a sample Code !! I hope this will help you !! 

Any Queries i can help Thanks !! :)
Photo of JW

JW

  • 140 Points 100 badge 2x thumb
I could create the URL but one thing is still an issue, it not linking back to the parent record. How do i link it back. Here's my code:

 <a href="https://www.quickbase.com/db/xxxxx?a=API_GenAddRecordForm&_fid_(Parent)=fid_(Child)"; class="Button">Next </a>
Photo of Ursula Ll

Ursula Ll

  • 1,450 Points 1k badge 2x thumb
Hi JW, So would the custom html page just have a button on it? if so, you can just add the button directly on the form, and create the URL to create a new record, using a formula text field:  
<a class='Vibrant Success' target='_blank' href=' " & URLRoot() & "db/" & [_DBID_TABLENAME] & "?a=API_GenAddRecordForm" '</a> 
You can add more fields to the url, so that those fields are already populated from the previous page, by adding the related table field id# (_fid_#) and the current table field name that correlates. For example: 
<a class='Vibrant Success' target='_blank' href=' " & URLRoot() & "db/" & [_DBID_TABLENAME] & "?a=API_GenAddRecordForm&_fid_7=" & URLEncode(Today())" '</a>
However, if the HTML page has more than just a button, then create a javascript page and attach it to the header of the HTML page. Grab the button element, and then just trigger the button using an API call, like API_AddRecord, or API_GenAddRecordForm. Just pull in the Record ID# of the Parent table and the table ID, and the API call will do the rest. Look at the API documentation to find sample xml requests to help you along. 
Photo of JW

JW

  • 140 Points 100 badge 2x thumb
I could create the URL but one thing is still an issue, it not linking back to the parent record. How do i link it back. Here's my code:

 <a href="https://www.quickbase.com/db/xxxxx?a=API_GenAddRecordForm&_fid_(Parent)=fid_(Child)"; class="Button">Next </a>
Photo of Ursula Ll

Ursula Ll

  • 1,450 Points 1k badge 2x thumb
So I found this discussion helpful: https://community.quickbase.com/quickbase/topics/button-to-redirect-to-current-form

Basically, the quickbase addition to your url to redirect once the record is generated is "&rdr=" & URLEncode($URL OF PARENT RECORD). In this case, the user is on the parent record before they are redirected to the new add form, so you need to grab the url here, before you are redirected, the fast and dirty way is using javascript: window.location.href. This literally just grabs the url exactly as it is on the page. Set it to a variable, and then send it along. Or, you can use Quickbase, doing the same type of url you did for the original url, pull in the data to send you back to the correct parent record. You will need to play around with how it redirects, and when. 

Also, if you are trying to create a new child record for the parent, then your url should state &_fid_(parent) = [Record id#], because the child record has not yet been created, you are creating it on the new page, and the _fid_(parent) (also by default called Related (whatever the table is called) on the child table) is being linked to the related parent record. 
(Edited)
Photo of JW

JW

  • 140 Points 100 badge 2x thumb
My URL is assuming the child record is new, its not trying to link back to the parent. So i m not really sure how do i go about.