Forum Discussion

RJIlg's avatar
RJIlg
Qrew Trainee
5 years ago

Copy to clipboard issue

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
------------------------------

8 Replies

  • 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
    ------------------------------
    • RJIlg's avatar
      RJIlg
      Qrew Trainee
      How do I do this without breaking the whole thing?

      ------------------------------
      RJ Ilg
      ------------------------------
      • BrandonDrake's avatar
        BrandonDrake
        Qrew Cadet
        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
        ------------------------------