Skip to main content
Question

XML error after API commands executed in text formula button

  • July 11, 2017
  • 0 replies
  • 80 views

I am receiving the following error when using a text-formula button -

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<qdbapi>
<action>API_AddRecord</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<rid>167</rid>
<update_id>1499802606114</update_id>
</qdbapi>

The code is performing the edit and add record functions.

// Begin button style
var text bgcolor = "#4D2DD2";
var text txtcolor = "white";
var text style = "style=\"text-decoration: none;\n\n box-shadow: 3px 3px 1px #888888; \n\n background:" & $bgcolor & ";\n\n border-radius: 3px;\n\n padding: 5px 8px;\n\n color: " & $txtcolor & ";\n\n display: inline-block;\n\n font: bold 700 24px/1 \"Calibri\", sans-serif;\n\n text-align: center;\n\n text-shadow:none;";
// End button style

"<a " & $style & " href='" &URLRoot() & "/db/"& Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] &
"&_fid_882=1" &
"&rdr=" &
URLEncode(URLRoot() & "db/" & [_DBID_Billing] & "?a=API_AddRecord&_fid_6=" & [Location ID])&
"&rdr="&
"javascript:" &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"

&"'>CRAZY</a>
This topic has been closed for replies.

  • Quickbase Alumni
  • July 12, 2017
It's not firing your last RDR, you can only have one RDR I think but there may be another way or another param you can use but I don't know it. It would be much easier to just add IOL and handle this in a .js page. Much more control over your pages and easier to code.

  • Author
  • Quickbase Alumni
  • July 12, 2017
My js abilities are limited at best. I can go to a specified report using this -
"&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() &
"?a=q&qid=1"))
This would be acceptable but being able to place the button in a form or any report and return to the place that the button was used would be the favored outcome. I have attempted a few other codes but the issue is always the fact that I am making an edit and creating a new record in another table.

  • Quickbase Alumni
  • July 12, 2017
This line:
"',function(){" &
has a single quote after the initial double quote - so you need to remove that, it's terminating your second rdr.
",function(){" &
Also you'll need to add an apptoken (assuming your app requires them)

  • Quickbase Alumni
  • July 13, 2017
You should be able to have multiple API calls in this.

Maybe make the URL actions variables, or separate fields so you can be sure they aren't causing the issue. 
Then bring them back together.

It looks like just a syntax thing, so just break them out to individual pieces to troubleshoot. 

  • Author
  • Quickbase Alumni
  • July 13, 2017
We did go through several iterations and split it up to do more. The formula executes still but ends at the error so we are leaning toward the redirect and java being the issue since it is a zero error. Here is what we have at this point(minus the button style)

var text URLOne = URLRoot() & "db/"& Dbid() & "?a=API_EditRecord&rid="& [Record ID#] &
"&_fid_882=1";

var text URLTwo = URLRoot() & "db/"& [_DBID_Billing]  & "?a=API_AddRecord" &
"&_fid_6=" & [Location ID] &
"&_fid_7=" & [Install Bill Amount] &
"&_fid_8=" & [Project ID] &
"&_fid_15=" & [Install Date] &
"&_fid_17=" & URLEncode([Installation Description]) &
"&_fid_19=" & [Type of Cancellation] &
"&_fid_20=" & [Install Bill Amount] &
"&_fid_22=" & [Address] &
"&_fid_23=" & [City] &
"&_fid_24=" & [State] &
"&_fid_25=" & [Postal Code] &
"&_fid_26=" & [County] &
"&_fid_27=" & [Country] &
"&_fid_28=" & [Related Project];

var text URLThree = URLRoot() & "db/"& [_DBID_Billing]  & "?a=API_AddRecord" &
"&_fid_6=" & [Location ID]&
"&_fid_8=" & [Project ID]&
"&_fid_15=" & [Install Date]&
"&_fid_22=" & [Address]&
"&_fid_23=" & [City]&
"&_fid_24=" & [State]&
"&_fid_25=" & [Postal Code]&
"&_fid_28=" & [Related Project];

"<a " & $style & " href='"
& $URLOne
& "&rdr=" & URLEncode($URLTwo)
& URLEncode("&rdr=" & URLEncode($URLThree))
& "javascript:"
& ",function(){"
& ".location.reload(true);"
& "});"
& "void(0);"

&"'>The Button Issue</a>

The xml is saying no error but you are missing the reload, is that correct ? any way , this is my suggestion. 

var text url1 = "[URL1]";
var text url1 = "[URL2]";

"javascript: "
&"    $.get($URL1,function(xml1){"
&"        if ( $(&quot;errcode&quot; , xml1).text() == &quot;0&quot;){"
&"               $.get($URL2,function(xml2){"
&"                    if ( $(&quot;errcode&quot; , xml2).text() == &quot;0&quot;){"
&"                         location.reload(true);   "                       "    
&"                    }else{ alert($(&quot;errtext&quot; , xml2).text() ) }"
&"                })"
&           }else{ alert($(&quot;errtext&quot; , xml1).text() ) }""
&"    })"


Keep in mind that you are writing three levels of encoding 
" ' &quot; text &quot;' " 

Hope this will help 

Regards

  • Author
  • Quickbase Alumni
  • August 16, 2017
Here is a sample of the solution, thanks to Kirk Trachy!

// Begin button style
var text bgcolor = "#A5E294";
var text txtcolor = "black";
var text style = "style=\"text-decoration: none; box-shadow: 3px 3px 1px #888888; background:" & $bgcolor & "; border-radius: 3px; padding: 5px 8px; color: " & $txtcolor & "; display: inline-block; font: bold 700 24px/1 \" Calibri\", sans-serif; text-align: center; text-shadow:none;";
// End button style


var text URL= URLRoot() & "db/"& Dbid() & "?a=API_EditRecord&rid="& [Record ID#] &
"&_fid_882=1"
&"&rdr="
&URLEncode(URLEncode(URLRoot() & "db/"& [_DBID_Billing]  & "?a=API_AddRecord" &
"&_fid_6=" & [Location ID]&
"&_fid_7=" & [Printer Bill Amount]&
"&_fid_8=" & [Project ID]&
"&_fid_9=" & [Install Date]&
"&_fid_10=" & [Type of Cancellation]&
"&_fid_11=" & [Install Bill Amount]&
"&_fid_12=" & [PO Number]
& "&rdr="
& URLEncode( URLRoot() & "db/"& [_DBID_Billing]  & "?a=API_AddRecord" &
"&_fid_6=" & [Location ID]&
"&_fid_7=" & [Printer Bill Amount]&
"&_fid_8=" & [Project ID]&
"&_fid_9=" & [Install Date]&
"&_fid_10=" & [Type of Cancellation]&
"&_fid_11=" & [Install Bill Amount]&
"&_fid_12=" & [PO Number]
& "&rdr="
& URLEncode( URLRoot() & "db/"& [_DBID_Billing]  & "?a=API_AddRecord" &
"&_fid_6=" & [Location ID]&
"&_fid_7=" & [Printer Bill Amount]&
"&_fid_8=" & [Project ID]&
"&_fid_9=" & [Install Date]&
"&_fid_10=" & [Type of Cancellation]&
"&_fid_11=" & [Install Bill Amount]&
"&_fid_12=" & [PO Number]))));


"<a " & $style & " href=\"javascript:" & "$.get('" & $URL & "', function(){" & "location.reload();" &
 "});" & "void(0);\">The Button Issue maybe</a>

.. or more simply now that we can color simply formula URL buttons

define your separate URL's and then combine like this.




$URLONE 
& "&rdr=" & URLEncode($URLTWO)
& URLEncode("&rdr=" & URLEncode($URLTHREE))
& URLEncode(URLEncode("&rdr=" & URLEncode($URLFOUR)))
& URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLFIVE))))

  • Author
  • Quickbase Alumni
  • August 17, 2017
Unfortunately Mark we are using buttons that change names, actions, colors, ability to place buttons anywhere the user wants without our QB team re-coding the buttons and give the end users that extra style that they want. Our business needs require all of this and URL buttons don't offer that. I did only put a rough code and at some point I could put a cleaner code if needed or you could contact me for a training session to help you understand this better.

Well maybe one day we will get button colorization formulas in the same way that we now have row colorization formulas.