Forum Discussion
CharlieMurawski
6 years agoQrew Cadet
Awesome contribution @Dana!! If I could add 1 small enhancement idea, in order to give it a more quickbase feel:
var text CB= URLEncode([Activity Details]);
var text Alert= URLEncode("Activity Details" & " were Copied to the Clipboard");
"<a class='Vibrant Success' style=\"border:0px solid green; background-color:green; text-align: center;\"href=" &
"javascript:{" &
"navigator.clipboard.writeText('" & $CB & "').then(function(){" &
"},function(){" &
"});" &
//"alert('" & $Alert & "');" &
"$.jGrowl('" & $Alert & "');" &
"};" &
">Copy to the Clipboard</a>"
Replacing your "alert" with "$.jgrowl" will throw the native QB growl message which is a little prettier than a javascript alert. FYI to everyone else -- this will work for any situation where you are using alerts in this fashion.
var text CB= URLEncode([Activity Details]);
var text Alert= URLEncode("Activity Details" & " were Copied to the Clipboard");
"<a class='Vibrant Success' style=\"border:0px solid green; background-color:green; text-align: center;\"href=" &
"javascript:{" &
"navigator.clipboard.writeText('" & $CB & "').then(function(){" &
"},function(){" &
"});" &
//"alert('" & $Alert & "');" &
"$.jGrowl('" & $Alert & "');" &
"};" &
">Copy to the Clipboard</a>"
Replacing your "alert" with "$.jgrowl" will throw the native QB growl message which is a little prettier than a javascript alert. FYI to everyone else -- this will work for any situation where you are using alerts in this fashion.
CharlieMurawski
6 years agoQrew Cadet
Glad to hear! I forgot to apply css, if you see the snippet below -- this will look EXACTLY like a native alert now :)
var text CB= URLEncode([Activity Details]);
var text Alert= URLEncode("Activity Details" & " were Copied to the Clipboard");
"<a class='Vibrant Success' style=\"border:0px solid green; background-color:green; text-align: center;\"href=" &
"javascript:{" &
"navigator.clipboard.writeText('" & $CB & "').then(function(){" &
"},function(){" &
"});" &
"$.jGrowl('" & $Alert & "',{theme:'jGrowl-green'});" &
"};" &
">Copy to the Clipboard</a>"
var text CB= URLEncode([Activity Details]);
var text Alert= URLEncode("Activity Details" & " were Copied to the Clipboard");
"<a class='Vibrant Success' style=\"border:0px solid green; background-color:green; text-align: center;\"href=" &
"javascript:{" &
"navigator.clipboard.writeText('" & $CB & "').then(function(){" &
"},function(){" &
"});" &
"$.jGrowl('" & $Alert & "',{theme:'jGrowl-green'});" &
"};" &
">Copy to the Clipboard</a>"
- AdamKeever15 years agoQrew CommanderThis works great, thanks for sharing.
I had to add \ , as @Mark Shnier (YQC) mentioned down further in this post, before an apostrophe to get it to copy correctly.
So for the \ and ' you need to have \\ and \' for the URLEncode to work properly. Not sure what other characters that is true for, but that could troublesome for some if the number of characters is high.
An If(Contains(),SearchAndReplace()) would probably be a good method for multiple characters.
------------------------------
Adam Keever
------------------------------- MarkShnier__You5 years ago
Qrew Legend
It's a very common problem that a single quote will mess up JavaScript buttons. One option depending on your use case is to have a SearchAndReplace function to remove the apostrophe before it hits the clipboard. Very often that' is not really necessary as for example a customer name might be Martha's Pie Company and maybe for the copy and paste purpose leaving out the ' doesn't really hurt.
------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
mark.shnier@gmail.com
------------------------------