Forum Discussion
MarkShnier__You
Qrew Legend
6 years agoI have put an app in the exchange which talks about how to make URL formuals, called URL formula for Dummies. There is also the famous Quick Base Evangelist Kirk Trachy's app called Magic Buttons in the Exchange.
But I'm in the mood so here is everything you need to know in one post for a low code no code pages solution for us dummies.
Here is an example of how to next URL formuals when you need to do successive steps. The nice thing about URL formuals as opposed to Automations, is that they happen right away so they can give a better user experience as you may be in a situation where the record is saved and refreshed before the Automation has a chance to act. Also right now Automations do not Copy when you Copy and app. But I often myself forget how much can be accomplished with Automations, which are no code. So Automations do deserve honourable mentions as a tool.
OK, but back to URL formuals. When you use a URL formula you need to do something at the end to either refresh the page or land the user on a report or a record, or else the system will feel compelled to spit out on the page the XML response to the last update - and even if successful it leaves the user no where and blurts what will look like an error message on the screen..
I always use formula variables as good practice to keep the code readable. Keep in mind that you may be the pour soul 5 years from now trying to remember what that button is doing. So you want to keep the code KISS.
Once you have defined the formula variables you nest them like this. So if you needed to do three things like edit, then add, and the land the user on display a record then you take three slices off the salami below.
$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))))))
Here is an example
var text AddRecord =
URLRoot() & "db/" & [_DBID_PO_DETAIL_LINES]
& "?act=API_AddRecord&_fid_6=" & URLEncode ([Purchase Order])
& "&_fid_17=" & [Qty]
& "&_fid_10=" & [Related Priced Material];
var text DeleteRecord =
URLRoot() & "db/" & [_DBID_PO_DETAIL_LINES]
& "?act=API_DeleteRecord&rid=" & [Record ID#];
var text DisplayRecord=
URLRoot() & "db/" & [_DBID_PURCHASE_ORDERS]
& "?a=dr&rid=" & [Purchase Order];
If(Nz([Unit Cost])=0 and [Current Cost]>0,
$AddRecord
& "&rdr=" & URLEncode($DeleteRecord)
& URLEncode("&rdr=" & URLEncode($DisplayRecord)))
note that if you have application tokens enabled, you will need a line inserted like
& "&apptoken=xcxcxcxcxcxcxcxcxcx"
so like this
var text AddRecord =
URLRoot() & "db/" & [_DBID_PO_DETAIL_LINES]
& "?act=API_AddRecord&_fid_6=" & URLEncode ([Purchase Order])
& "&apptoken=xcxcxcxcxcxcxcxcxcx"
& "&_fid_17=" & [Qty]
& "&_fid_10=" & [Related Priced Material];
So that work fine, except its often nice to have a button which will work on a record or a report even a button on an embedded child report on a record so that the button is not specific to where the user is and you just want to click and refresh the page they are on.
So this will work. It runs the URL formula variable and refreshes the page.
var text URL = .........;
"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"
So the last issue is if you want the URL to do multiple steps (multiple API calls) and then refresh the page (record or report or even dashboard page) using the javascript.
I do not have the definitive answer to that. I'm pretty sure that if you nest the URL calls "too" deep then the javascript refresh method will not work. But I think that two deep may work. I'm actually not 100% sure of the limits.
So this might works, and you can try it and report back as you are trying to do 2 steps and refresh the page.
var text URLONE = .....;
var text URLTWO = ....;
var text URL = $URLONE
& "&rdr=" & URLENcode($URLTWO);
"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"
Almost Lastly, if you do not want to refresh the page but just put up a quiet green fade way pop up, then use this for the javascript for a 5,000 millisecond pop up.
"javascript:" &
"$.get('" &
$url &
"',function(){" &
"$.jGrowl('This Item has been put on PO CANCEL snooze', {life: 5000, theme: 'jGrowl-green'});" &
"});" &
"void(0);"
and Last lastly, if you need to run a URL formula variable called URL and then refresh the page but want to have a 2 second delay to allow and Automation time to complete before displaying he refreshed page
"javascript:" &
"$.get('" &
$URL &
"',setTimeout(function(){" &
"location.reload(true);" &
"},2000));"
& "void(0);";
------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
markshnier2@gmail.com
------------------------------
But I'm in the mood so here is everything you need to know in one post for a low code no code pages solution for us dummies.
Here is an example of how to next URL formuals when you need to do successive steps. The nice thing about URL formuals as opposed to Automations, is that they happen right away so they can give a better user experience as you may be in a situation where the record is saved and refreshed before the Automation has a chance to act. Also right now Automations do not Copy when you Copy and app. But I often myself forget how much can be accomplished with Automations, which are no code. So Automations do deserve honourable mentions as a tool.
OK, but back to URL formuals. When you use a URL formula you need to do something at the end to either refresh the page or land the user on a report or a record, or else the system will feel compelled to spit out on the page the XML response to the last update - and even if successful it leaves the user no where and blurts what will look like an error message on the screen..
I always use formula variables as good practice to keep the code readable. Keep in mind that you may be the pour soul 5 years from now trying to remember what that button is doing. So you want to keep the code KISS.
Once you have defined the formula variables you nest them like this. So if you needed to do three things like edit, then add, and the land the user on display a record then you take three slices off the salami below.
$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))))))
Here is an example
var text AddRecord =
URLRoot() & "db/" & [_DBID_PO_DETAIL_LINES]
& "?act=API_AddRecord&_fid_6=" & URLEncode ([Purchase Order])
& "&_fid_17=" & [Qty]
& "&_fid_10=" & [Related Priced Material];
var text DeleteRecord =
URLRoot() & "db/" & [_DBID_PO_DETAIL_LINES]
& "?act=API_DeleteRecord&rid=" & [Record ID#];
var text DisplayRecord=
URLRoot() & "db/" & [_DBID_PURCHASE_ORDERS]
& "?a=dr&rid=" & [Purchase Order];
If(Nz([Unit Cost])=0 and [Current Cost]>0,
$AddRecord
& "&rdr=" & URLEncode($DeleteRecord)
& URLEncode("&rdr=" & URLEncode($DisplayRecord)))
note that if you have application tokens enabled, you will need a line inserted like
& "&apptoken=xcxcxcxcxcxcxcxcxcx"
so like this
var text AddRecord =
URLRoot() & "db/" & [_DBID_PO_DETAIL_LINES]
& "?act=API_AddRecord&_fid_6=" & URLEncode ([Purchase Order])
& "&apptoken=xcxcxcxcxcxcxcxcxcx"
& "&_fid_17=" & [Qty]
& "&_fid_10=" & [Related Priced Material];
So that work fine, except its often nice to have a button which will work on a record or a report even a button on an embedded child report on a record so that the button is not specific to where the user is and you just want to click and refresh the page they are on.
So this will work. It runs the URL formula variable and refreshes the page.
var text URL = .........;
"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"
So the last issue is if you want the URL to do multiple steps (multiple API calls) and then refresh the page (record or report or even dashboard page) using the javascript.
I do not have the definitive answer to that. I'm pretty sure that if you nest the URL calls "too" deep then the javascript refresh method will not work. But I think that two deep may work. I'm actually not 100% sure of the limits.
So this might works, and you can try it and report back as you are trying to do 2 steps and refresh the page.
var text URLONE = .....;
var text URLTWO = ....;
var text URL = $URLONE
& "&rdr=" & URLENcode($URLTWO);
"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"
Almost Lastly, if you do not want to refresh the page but just put up a quiet green fade way pop up, then use this for the javascript for a 5,000 millisecond pop up.
"javascript:" &
"$.get('" &
$url &
"',function(){" &
"$.jGrowl('This Item has been put on PO CANCEL snooze', {life: 5000, theme: 'jGrowl-green'});" &
"});" &
"void(0);"
and Last lastly, if you need to run a URL formula variable called URL and then refresh the page but want to have a 2 second delay to allow and Automation time to complete before displaying he refreshed page
"javascript:" &
"$.get('" &
$URL &
"',setTimeout(function(){" &
"location.reload(true);" &
"},2000));"
& "void(0);";
------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
markshnier2@gmail.com
------------------------------
- ChrisFaye16 years agoQrew CadetThank You so much, Mark!
I did look through Kirk's Magic Buttons app and stumbled a bit. Downloaded yours and the explanation got me moving! Also, thank you for throwing everything into the post as well!
2 questions if you have time
- Is there any way to code in larger pop-ups or a directory I could look to? I'm thinking about either making the pop-up bigger or centering it on the page.
- Is there a correct way of combining the refresh with the pop-up?
Here's what I've got that seems to be functioning except for trying to get the pop-up to display following the refresh. I tried a few ways with no luck and here's what I ended up with.
// edit the record
var text URLONE = URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_19=" & URLEncode(UserToName(User()))
& "&apptoken=...";
// Add record in 'Duplicate Test' Table & copy fid 6 to [Name]
var text AddRecord =URLRoot() & "db/" & [_DBID_DUPLICATE_TEST]
& "?act=API_AddRecord"
& "&apptoken=..."
& "&_fid_6=" & [Name];
//Refresh, Display Current Original Record and Display Green pop-up for 15 seconds
var text DisplayRecord=
URLRoot() & "db/" & Dbid()
& "?a=dr&rid=" & [Record ID#]
& "&apptoken=..."
&
"javascript:" &
"$.get('" &
$URLONE &
"',function(){" &
"$.jGrowl('This File has been Approved For Invoicing', {life: 15000, theme: 'jGrowl-green'});" &
"});" &
"void(0);";
$URLONE
& "&rdr=" & URLEncode($AddRecord)
& URLEncode("&rdr=" & URLEncode($DisplayRecord))
Thanks Again!
------------------------------
Chris
------------------------------- MarkShnier__You6 years ago
Qrew Legend
re: 2 questions if you have time
- Is there any way to code in larger pop-ups or a directory I could look to? I'm thinking about either making the pop-up bigger or centering it on the page.
- Is there a correct way of combining the refresh with the pop-up?
For all those questions, there may be a way, but other's smarter than me would have to chime in.
------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
markshnier2@gmail.com
------------------------------ - ChrisFaye16 years agoQrew CadetThink I found some info on the jGrowl options, but if you have any thoughts I'm all ears.
Regarding the formula, I also tried it this way with no success -
// edit the record
var text URLONE = URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_19=" & URLEncode(UserToName(User()))
& "&apptoken=da5rkk4b9jnqzmdbatsp2bffnnum";
// Add record in 'Duplicate Test' Table & copy fid 6 to [Name]
var text AddRecord =URLRoot() & "db/" & [_DBID_DUPLICATE_TEST]
& "?act=API_AddRecord"
& "&apptoken=da5rkk4b9jnqzmdbatsp2bffnnum"
& "&_fid_6=" & [Name];
//Refresh, Display Current Original Record
var text DisplayRecord=
URLRoot() & "db/" & Dbid()
& "?a=dr&rid=" & [Record ID#]
& "&apptoken=da5rkk4b9jnqzmdbatsp2bffnnum";
//Display Green pop-up for 15 seconds
var text URL =
"javascript:" &
"$.get('" &
$URLONE &
"',function(){" &
"$.jGrowl('This File has been Approved For Invoicing', {life: 15000, theme: 'jGrowl-green'});" &
"});" &
"void(0);";
//String
$URLONE
& "&rdr=" & URLEncode($AddRecord)
& URLEncode("&rdr=" & URLEncode($DisplayRecord))
& URLEncode (URLEncode("&rdr=" & URLEncode($URL)))
------------------------------
Chris
------------------------------- MarkShnier__You6 years ago
Qrew Legend
First of all, it does not make sense to both try to refresh the page with the javascript and also have a triple redirect where the last step is to redisplay the record. So if you want to try to do the first two steps as the URL, then try that.
Also I assume that the definition of the formula variable for URLONE needs to be before it is used, but maybe it does not. Just seems strange to me to have it below the javascript.
------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
markshnier2@gmail.com
------------------------------