Forum Discussion
MarkShnier__You
3 years agoQrew Legend
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
------------------------------
------------------------------
Mark Shnier (YQC)
mark.shnier@gmail.com
------------------------------
- ChrisSwirtz33 years agoQrew MemberHey 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
------------------------------- MarkShnier__You3 years agoQrew Legendnp
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
------------------------------- ChrisSwirtz33 years agoQrew MemberThanks 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
------------------------------