Skip to main content
Question

Sequential Operations in Formula fields.

  • June 27, 2021
  • 0 replies
  • 31 views

Hello,

This post is regarding the future behavior of Formula fields.

Often we need to perform sequential operations using the Quickbase API's(API_EditRecord, API_PurgeRecords etc). In some requirements we often need to perform the 2nd API call only after the 1st one has completed, since JavaScript is going to be prohibited anywhere other than QB code pages we would need another way to perform such an operation.

An example of this kind of operation:

This is the code of field type "URL (formula)" which shows as a button.

var text url_1 =
URLRoot() & "db/" &Dbid()& "?a=API_EditRecord" &
"&rid=" & [Record ID#] &
"&apptoken=xxxxxxxxxx" &
"&_fid_9987=" & [Current User];


var text url_2 =
URLRoot() & "db/" &Dbid()& "?a=API_EditRecord" &
"&rid=" & [Record ID#] &
"&apptoken=xxxxxxxxxx" &
"&_fid_889=clear";


If([Prod Status]="Done",
"javascript:" & "$.get('" & $url_1 & "',\nfunction(){" &"$.get('" & $url_2 & "');"&"});\n"&"void(0);"
,null) //Using the jQuery "get" method.

In the above example $url_2 has to be carried out only when $url_1 has finished, jQuery get method allows us to do nested calls. The get method of $url_2 is invoked only after the callback function of $url_1 is called. 

This will be a helpful way in many scenarios.

​​​

------------------------------
Himanshu Sharma
------------------------------
This topic has been closed for replies.

MarkShnierYou
Forum|alt.badge.img+24
This is the generic syntax for sequential URL API calls.  Just slice off as much of the salami as you need.  

$URLONE
& "&rdr=" & URLEncode($URLTwo)
& URLEncode("&rdr=" & URLEncode($URLThree))
& URLEncode(URLEncode("&rdr=" & URLEncode($URLFour)))
& URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLFive))))
& URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSix)))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSeven))))))
& URLENcode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLEight)))))))
& URLENcode(URLENcode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLNine))))))))
& URLENcode(URLENcode(URLENcode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLTen)))))))))

For example this is one with three steps

var text URLONE = URLRoot() & "db/" & [_DBID_FOCUS_INVOICE]
& "?act=API_EditRecord&rid=1"
& "&_fid_6=" & ToText([Record ID#])
& "&_fid_9=" & ToText([Related Client]);

var text URLTWO = URLRoot() & "db/" & [_DBID_TIME_RECORDS]
& "?act=API_RunImport&ID=11";

var text URLTHREE = var text RefreshPage =  URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

If([# of Time Records]=0,
$URLONE
& "&rdr=" & URLEncode($URLTWO)
& URLEncode("&rdr=" & URLEncode($URLTHREE))
)


Note that the last step is syntax to refresh the page.  The last step of these type for formula needs to land the user on a record or a report or a Page.  It's useful to have this code so that the same button can be used on a report or a record.

------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
mark.shnier@gmail.com
------------------------------