Forum Discussion

Re: Button that creates a new record based on the selection in the new record

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 Replies

  • ChrisSwirtz3's avatar
    ChrisSwirtz3
    Qrew Member
    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
    ------------------------------
    • MarkShnier__You's avatar
      MarkShnier__You
      Icon for Qrew Legend rankQrew Legend
      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
      ------------------------------
      • ChrisSwirtz3's avatar
        ChrisSwirtz3
        Qrew Member
        So it would look something like this?



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