Discussions

 View Only
  • 1.  Button that creates a new record based on the selection in the new record

    Posted 05-13-2022 14:58
    I have an app with a Companies Table and a Offices Table related by a one Company to many Offices relationship. When a Company wants to create a new Office request, there is a few types of request to choose from (New, Renewal, Relocation), based on which choice is selected, certain info is shown/hidden on the Office record.

    Is it possible to create a button on the Company table that when clicked will create a new record in the Office table utilizing the specific type of request the user wants?

    For instance, if ABC Company wants to Renew a current office space, they would be able to click on a "Renew" Button and it will create a New Office record where "Renew" is already selected in the Type: dropdown so the correct information is already shown/hidden.

    Purpose being to save the user the step of having to click the New Office button and then selecting the type of Request from the dropdown.

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


  • 2.  RE: Button that creates a new record based on the selection in the new record

    Posted 05-13-2022 15:04
    Can you post (copy/paste)  the code for your current Add Office button, and let me know the field ID# of the field you want to populate. The I will show you the simple change to the code.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 3.  RE: Button that creates a new record based on the selection in the new record

    Posted 05-13-2022 16:46
    Hey Mark, here is the code as is.

    URLRoot() & "db/" & [_DBID_SPACES] & "?a=API_GenAddRecordForm&_fid_1115=" & URLEncode ([Record ID#])& "&z=" & Rurl()

    And the field ID that I want to populate is 12

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



  • 4.  RE: Button that creates a new record based on the selection in the new record

    Posted 05-13-2022 17:27
    Edited by Mark Shnier (Your Quickbase Coach) 05-13-2022 17:42
    np

    URLRoot() & "db/" & [_DBID_SPACES]
    & "?a=API_GenAddRecordForm"
    & "&_fid_1115=" & URLEncode ([Record ID#])
    & "&_fid_12="Renewal"
    & "&z=" & Rurl()

    Just a note about URLEncode

    It never hurts to do URLEncode but when you do it needlessly it just clutters up your formulas and makes them unreadable. In the whole Internet certain characters are not allowed, for example you may have noticed that there are never spaces in a URL. So if for example you wanted to populate "New Lease" into that field, that string has a space in it and would make an illegal URL. So if you were not sure what was going to be put into that field, perhaps it was not a simple hardcoded value but was actually coming from a data field then the syntax would be this 


    URLRoot() & "db/" & [_DBID_SPACES] & "?a=API_GenAddRecordForm"
    & "&_fid_1115=" & URLEncode ([Record ID#])
    & "&_fid_12=" & URLEncode("New Lease")
    & "&z=" & Rurl()
      

    You will also notice how I broke up your formula into separate lines to keep everything in a consistent pattern. It really pays off to keep your formulas stupid simple to read because a month or a week or a year from now you may be the poor soul who needs to figure out what that formula is doing.  Or you may want to be kind to your successor who takes over from you eventually.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 5.  RE: Button that creates a new record based on the selection in the new record

    Posted 05-17-2022 16:47
    Thanks again Mark, this worked well, as per usual.

    I wonder if this can be incorporated with the solution you provided in regard to linking users to a specific company?

    Basically the client wants a Company user to be able to log into the app, and from the home screen be able to create a specific type of New Office Request (i.e., New Annual Lease, Renewal) which is based on a selection in the New Office Form, for the specific Company that user is linked to. Can I combine both solutions you provided to accomplish this?

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



  • 6.  RE: Button that creates a new record based on the selection in the new record

    Posted 05-17-2022 17:23
    Yes, that is possible.  You would display a "report" of those users we discussed on the home page filtered where the User is the current user.  So it will be a one record report.  The only fields that you need to offer are the ones like [Create New Annual]  or [Create Renewal].

    Since the user record knows their office, you would just adjust the buttons to have an extra line like

    & "&_fid_999=" & [Related User Office]

    so that he correct Office auto populates  .. although I think that we were going to also do that via a form rule anyways so this is sort of belt and suspenders.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 7.  RE: Button that creates a new record based on the selection in the new record

    Posted 05-18-2022 09:20
    So it would look something like this?



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



  • 8.  RE: Button that creates a new record based on the selection in the new record

    Posted 05-18-2022 09:26
    yes

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 9.  RE: Button that creates a new record based on the selection in the new record

    Posted 05-18-2022 09:30
    Ok excellent, thanks! I was hoping there was a way to be able to break those buttons out on their own but I think this will end up working just find.

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