Skip to main content
Question

Page Refresh Challenge and Symptom

  • March 27, 2017
  • 0 replies
  • 29 views

I have a two have formula field buttons with different yet similar functionality. 

The first one:
  • Clones an existing table record, with its related detail records, that a user is viewing/editing (Successfully)
  • Changes a field value on the new record (Successfully)
  • Refreshes the screen placing the user in the new record (Successfully)
var text Clone = URLRoot() &"db/"  & [_DBID_WIDGETS] & "?act=API_CopyMasterDetail&destRID=0" & "&sourcerid=" & [Record ID#] & "&copyfid=52" &  "&apptoken=######";

var text ValueUpdate = URLRoot() &"db/"  & [_DBID_WIDGETS] & "?act=API_EditRecord&rid=" & [Clone Record ID#] &  "&_fid_54=" & "False" & "&apptoken=######";

var text RefreshRecord=URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Clone Record ID#] & "&apptoken=######";

$Clone & "&rdr=" & URLEncode($ValueUpdate) & URLEncode("&rdr=" & URLEncode($RefreshRecord))

The second one:
  • Calls an Azure Cloud API that copies WIDGETS and DETAILS to another system (Successfully)
  • Changes a field value on the current record (makes a checkbox "true") (Successfuly)
  • Refreshes the screen placing the user again in the current record (Not Successfully)
var text AzureAPI = "http://#######.azurewebsites.net/api/########?db="; & [_DBID_WIDGET_DETAILS] & "&rid=" & [Record ID#];

var text Processed = URLRoot() &"db/"  &  [_DBID_WIDGETS] & "?act=API_EditRecord&rid=" & [Record ID#] &  "&_fid_60=" & "True" & "&apptoken=######";

var text RefreshRecord=URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#] & "&apptoken=######";

$AzureAPI & "&rdr=" & URLEncode($Processed) & URLEncode("&rdr=" & URLEncode($RefreshRecord))

Unfortunately this doesn't refresh the page of the current record. It actually brings the user to the default List All screen of WIDGETS table.

I've tried a variation of the formula. Here is an example.

$AzureAPI & "&rdr=" & URLEncode($Processed) & URLEncode("&rdr=" & URLEncode("javascript:" & location.reload(true);" & "$.get('" & $RefreshRecord & "');" &"void(0);"))

But to no avail ... 

However if I remove the initial AzureAPI call ... the $RefreshRecord works as expected.

$Processed & "&rdr=" & URLEncode($RefreshRecord)

That is great but it defeats the purpose. Clearly when the AzureAPI URL call executes and then returns, it is throwing off the current page focus, and QuickBase is bouncing the user to the main WIGETS table default List ALL page.

Any help would be greatly appreciated.
This topic has been closed for replies.

  • Quickbase Alumni
  • March 27, 2017
The answer is very simple, the Azure API URL simply does not know what to do with the rdr parameter because it is not part of their API scheme so it ignores it.

$AzureAPI & "&rdr=" & URLEncode($Processed) & URLEncode("&rdr=" & URLEncode($RefreshRecord))

You can gain complete control of what happens after you make AJAX calls by doing everything in script rather than the formula language.

  • Author
  • Quickbase Alumni
  • March 27, 2017
Ok I appreciate it ... So how would you re-code it based on your comments?

The reason I ask is because I am not a javascript guy.

  • Author
  • Quickbase Alumni
  • March 27, 2017
I am please asking for assistance in rewriting my code below in javascript per the recommendation made above. I haven't programmed in it and I really need a resolution to my problem. Your help would be greatly appreciate. 

Thank you

Formula field code that needs to be rewritten

var text AzureAPI = "http://#######.azurewebsites.net/api/########?db="; & [_DBID_WIDGET_DETAILS] & "&rid=" & [Record ID#];

var text Processed = URLRoot() &"db/"  &  [_DBID_WIDGETS] & "?act=API_EditRecord&rid=" & [Record ID#] &  "&_fid_60=" & "True" & "&apptoken=######";

var text RefreshRecord=URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#] & "&apptoken=######";

$AzureAPI & "&rdr=" & URLEncode($Processed) & URLEncode("&rdr=" & URLEncode($RefreshRecord))

Typically writing script is beyond what developers offer for free on this forum. I suggest you contact Dan directly and engage him to do the work. I have used Dan in the past myself when non native coding is required.