Discussions

Expand all | Collapse all

Copy to clipboard issue

  • 1.  Copy to clipboard issue

    Posted 24 days ago

    So I'm using the following formula as a Copy Content button:

    var text CB= URLEncode([SFY PO Number] & " - " & [HO Last Name] & " - " & [HO Street Address] & " - " & [Client Company Name]);
    var text Alert= URLEncode("Current Job Info" & " was Copied to the Clipboard");
    "<a class='Vibrant Success' style=\"border:0px solid green; background-color:green; text-align: center;-box-shadow: 0px 10px 13px -7px #000000, 9px 7px 12px 6px #000000; \nbox-shadow: 0px 10px 13px -7px #000000, 9px 7px 12px 6px #000000;\"href=" &
    "javascript:{" &
    "navigator.clipboard.writeText('" & $CB & "').then(function(){" &
    "},function(){" &
    "});" &
    //"alert('" & $Alert & "');" &
    "$.jGrowl('" & $Alert & "');" &
    "};" &
    ">Copy to the Clipboard</a>"

    So here's the issue: Anytime that there is an apostrophe in one of the fields (For example, [HO Street Address]= 2300 Henry's Drive) then the button refuses to work. Are there any edits I can make to the formula to ignore any future apostrophes?



    ------------------------------
    RJ Ilg
    ------------------------------


  • 2.  RE: Copy to clipboard issue

    Posted 24 days ago
    RJ, 

    Have you tried to URLEncode each field, or at least the fields that may contain an apostrophe, individually.  I ran into a similar issue and when I encoded the field causing the issue by itself, it fixed the issue.

    ------------------------------
    Brandon Drake
    JHI Group
    Monroeville OH
    ------------------------------



  • 3.  RE: Copy to clipboard issue

    Posted 24 days ago
    How do I do this without breaking the whole thing?

    ------------------------------
    RJ Ilg
    ------------------------------



  • 4.  RE: Copy to clipboard issue

    Posted 24 days ago
    Apostrophes are often a problem and URLENCoding will not fix them, as I see you are already URLEncoding.

    Try replacing your first line with these two lines.

    var text CBRaw= URLEncode([SFY PO Number] & " - " & [HO Last Name] & " - " & [HO Street Address] & " - " & [Client Company Name]);

    var text CB = SearchAndReplace($CBRaw,"'","");


    That should simply strip out the single quote and convert 

    Henry's to Henrys




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



  • 5.  RE: Copy to clipboard issue

    Posted 24 days ago
    RJ, 

    Actually, looking at the code.  You should just be able to replace your single quotes around $CB with \" like so 
    "navigator.clipboard.writeText(\"" & $CB & "\").then(function(){" &

    ------------------------------
    Brandon Drake
    JHI Group
    Monroeville OH
    ------------------------------



  • 6.  RE: Copy to clipboard issue

    Posted 24 days ago

    That works! Thanks!

    Full functioning rich text formula:
    var text CB= URLEncode([SFY PO Number] & " - " & [HO Last Name] & " - " & [HO Street Address] & " - " & [Client Company Name]);
    var text Alert= URLEncode("Current Job Info" & " was Copied to the Clipboard");
    "<a class='Vibrant Success' style=\"border:0px solid green; background-color:green; text-align: center;-box-shadow: 0px 10px 13px -7px #000000, 9px 7px 12px 6px #000000; \nbox-shadow: 0px 10px 13px -7px #000000, 9px 7px 12px 6px #000000;\"href=" &
    "javascript:{" &
    "navigator.clipboard.writeText(\"" & $CB & "\").then(function(){" &
    "},function(){" &
    "});" &
    //"alert('" & $Alert & "');" &
    "$.jGrowl('" & $Alert & "');" &
    "};" &
    ">Copy to the Clipboard</a>"



    ------------------------------
    RJ Ilg
    ------------------------------