Discussions

Expand all | Collapse all

Utilizing a different form when clicking the "Add Record" button

  • 1.  Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 14:10
    I'm looking to have a user utilize a different form to add a record to a table depending on which table they are adding the record from.

    I assume this can be done via some sort of URL Report field , just not sure where to indicate what form it is routed to in the child table.

    ------------------------------
    Chris Swirtz
    ------------------------------


  • 2.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 14:17
    Edited by Austin K 02-07-2020 14:19
    You can either pick what form each role will use for Add, Edit, or View on the table itself in the Forms section under "Set how different roles use these forms" or you can set it in the URL by doing &dfid=MyFormNumberHere. I'm not positive the first one would work when doing it via the URL but you could explore that and see. I think it should work.

    Edit: After reading again you definitely want the second option using dfid. But the first option is there for another time.


  • 3.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 16:23
    Chris,

    Here is an example that works the way Austin laid out

    var text URLGenAdd =
      URLRoot() & "db/" & Dbid() &
      "?a=API_GenAddRecordForm&_fid_8=" & URLEncode ([Record ID#])&
      "&dfid=10" &
      "&z=" & Rurl();


    This will add a new record using Form Ten.  It also fills in field 8 with the Record ID # from where you started.

    Change Dbid() to a table alias to pick a different table to be adding the record using Form Ten from that table.​

    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------



  • 4.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 16:41
    So this is the code I end up with:

    var text URLGenAdd=URLRoot() & "db/" & [_DBID_PERIPHERALS] & "?a=API_GenAddRecordForm&_fid_15" & URLEncode ([Record ID#])&"&dfid=11" & "&z=" & Rurl();

    But it puts a little yellow mark at the end and gives me an error. What am I doing wrong?

    ------------------------------
    Chris Swirtz
    ------------------------------



  • 5.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 16:45
    It accepted the code before when I originally forgot to add the "var text URLGenAdd =" part of the formula but when I clicked the button it still just took me to the add new record utilizing the main form, not form 11 like I want it to.

    When I hover the cursor over the yellow section a note pops up saying "Expecting Test"


    ------------------------------
    Chris Swirtz
    ------------------------------



  • 6.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 16:46
    Chris,

    What is the whole set of code you put into the Formula Rich Text box.   Your GenAdd looks good, I am suspicious you have an error in the UI portion.

    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------



  • 7.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 16:51
    Oh, that might be the problem, I am using a URL Formula type field, not a Rich Text Formula field. The formula I pasted above is exactly what I have in there now.

    ------------------------------
    Chris Swirtz
    ------------------------------



  • 8.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 16:54
    I just tried the same formula in a Rich Text Formula field and it's giving me the same error

    var text URLGenAdd=URLRoot() & "db/" & [_DBID_PERIPHERALS] & "?a=API_GenAddRecordForm&_fid_15" & URLEncode ([Record ID#])&"&dfid=11" & "&z=" & Rurl();

    ------------------------------
    Chris Swirtz
    ------------------------------



  • 9.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 16:59

    Chris,

    That is it.  Change the field type.


    // Images
    var text IMGLock  =     "<img src=https://images.quickbase.com/si/48/045-lock.png>"

    // URL
    var text URLGenAdd=
    URLRoot() & "db/" & [_DBID_PERIPHERALS] &
    "?a=API_GenAddRecordForm&_fid_15=" & URLEncode ([Record ID#]) &
    "&dfid=11" & "&z=" & Rurl();

    // UI
     "<a href=" & $URLGenAdd & "' title=\"Click Me\">"  & $IMGLock &  "</a>"


    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------



  • 10.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 17:14
    Chris,

    By the way, change the image at the top to something that makes sense for your user base.  I use that lock as default for status changes to records.   It is probably nonsensical for your business case.

    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------



  • 11.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 17:16
    Well Don, that worked, thank you. Couple things though...

    1. Is there way to show a button instead of that lock picture?
    2. this type of field does not have the option to open in a new window like others do (unless you right click and select that from the menu, which they won't want to do). This is something my boss is definitely going to ask for.

    ------------------------------
    Chris Swirtz
    ------------------------------



  • 12.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-07-2020 17:36
    Edited by Don Larson 02-07-2020 19:18
    Chris,

    Images hosted by Quick Base
    https://login.quickbase.com/db/9kaw8phg?a=ShowPage&pageid=160  

    Custom Built but you have to put on a web server
    https://dabuttonfactory.com/


    To open in a new tab you need to insert the HTML code for it.
    "<a href=" & $URLGenAdd & "' target=\"_blank\">"  & $IMGLock &  "</a>"

    This is all HTML.  The concept is simple but the syntax and quote marks get tricky.

    Spend some time on W3 and you will be able to do amazing stuff
    https://www.w3schools.com


    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------



  • 13.  RE: Utilizing a different form when clicking the "Add Record" button

    Posted 02-26-2020 21:10
    Hi Chris,

    I came across this thread in the Quick Base Newsletter and thought I'd chime in.

    You can still use the Formula URL field as you desired (shown as a button and open in a new window). Just drop the variable portion of the formula you're using such as this...
    URLRoot() & "db/" & [_DBID_PERIPHERALS] &
    "?a=API_GenAddRecordForm&_fid_15" &
    URLEncode ([Record ID#])&"&dfid=11" & "&z=" & Rurl()


    There are also ways to format the rich text formula to open in a new window and show as a button, but it's likely not worth the extra coding if you just simplify the formula and use the Formula URL button.

    Let me know if this helps 😊👍



    ------------------------------
    Sharon Faust (QuickBaseJunkie.com)
    Founder, Quick Base Junkie
    https://quickbasejunkie.com
    ------------------------------