change field properties with a button

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

We sometimes import an entire project with tasks into our QuickBase app from another application and it works fine, however we have tightened up our system a little bit by making some fields required on entry.  Its not practical to individually switch off the required fields and then switch them back on again so I was looking to create a button or two to do this. 

I created a Formula Url field and gave it this formula but of course the syntax is not right.

Im trying to set required to 0 for field 139 in the tasks table:

URLRoot()& "db/“ &[_DBID_TASKS]& "?a=API_SetFieldProperties&_fid_139

“&required=0" & 

"&rdr=" & 

URLEncode(URLRoot() & "db/" & Dbid())

Can someone set me on the right path?

Tks

Photo of Michael Graham | Insight Global UK

Posted 4 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,064 Points 20k badge 2x thumb
I think you are missing an equal sign on the fid parameter and closing quote on this line:

URLRoot()& "db/“ &[_DBID_TASKS]& "?a=API_SetFieldProperties&fid=139" &

You may also need to add an apptoken parameter to the URL.
I changed it as above but now get this:

There are extra characters beyond the end of the formula.

URLRoot()& "db/“ &[_DBID_TASKS]& "  ?a=API_SetFieldProperties&fid=139" &
“&required=0" &
"&rdr=" &
URLEncode(URLRoot() & "db/" & Dbid())
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,064 Points 20k badge 2x thumb
you are missing a double quote after the three characters: db/

You also have extra spaces before the ? character.
This is what I have now:

URLRoot()& "db/" &[_DBID_TASKS]&"?a=API_SetFieldProperties&fid=139"&
“&required=0"&
"&rdr="&
URLEncode(URLRoot() & "db/" & Dbid())

with this error:

Expected a valid expression after the "&"

but im not sure to where that refers?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,064 Points 20k badge 2x thumb
You have the wrong type of quote before the &required property. The character you have is called a curly quote and was probably introduced by cutting and pasting from a Microsoft Office document.
Eagle Eyes!   Superb, that did the trick Thanks!
Its now working fine on the single field with this formula:

URLRoot()& "db/" &[_DBID_TASKS]&"?a=API_SetFieldProperties&fid=139"&"&required=0"&"&rdr="&
URLEncode(URLRoot() & "db/" & Dbid())

But is it possible to pass this to multiple fields like 5, 12, 75,
I have messed about with all sorts of options like adding &fid=5 onto the first field but it wont take it.
Can't find anything in the Help Guides.

??
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,064 Points 20k badge 2x thumb
Calling the API through a formula URL will restrict you to doing one thing at a time and force a new page to load which displays the XML response of the API call (which is not intended to be displayed in your browser because XML isn't HTML). To some extent  you can disguise these page loads and immediately redirect to another URL (using the rdr parameter) which invokes a second URL which makes further API calls. However this scheme becomes very difficult to continue if you have more than two API URLs to invoke. Moreover, chaining API URLs together like this makes it impossible to examine response to any individual API or conditionally invoke the next API method. By using this scheme of adding rdr parameters to a formula URL you unconditionally invoke the next URL specified. You are severely making your life more complicated if you exclusively use this scheme when you have to accomplish multiple actions. In other words, you should only use the API through formula URLs when you have a single trivial API method to call.

The proper way to use the API is through a script language from which you can make any number of API calls and examine the response before proceeding to the next step. To implement this you create a button which when clicked will execute JavaScirpt which is saved in a user defined page. In the user defined page you can put any number of API calls and implement any logic you desire - without the page reloading.
Looks like I'll have to learn Javascript then :)
Thanks again for you help!