We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to Replicate copyToClipboard function with Custom Message instead of Copied to Clipboard

mounimouni
Giga Contributor

I have a requirement to put a custom message in the place of "Copied to Clipboard" when clicked on a share symbol(macro) in KB.

Message needs to be replaced with a message like "Link for the article is copied to memory"..

Could some one help..

Following is the link that has the macro:

https://YOURINSTANCE.service-now.com/nav_to.do?uri=%2Fsys_ui_macro.do%3Fsys_id%3D3783deb1d70031004792a1737e610391%26sysparm_record_target%3Dsys_ui_macro%26sysparm_record_row%3D1%26sysparm_record_rows%3D1%26sysparm_record_list%3DnameSTARTSWITHkb_view_common_footer_metadata_fields%255EORDERBYname

5 REPLIES 5

As workaround added below two lines:

g_form.addInfoMessage('Copied to clipboard');
setTimeout(g_form.clearMessages, 3000);

 

instead of : 

 if (!messageMethod || messageMethod == 'GlideUI') {
            var span = document.createElement('span');
            span.setAttribute('data-type', 'info');
            span.setAttribute('data-text', 'Copied to clipboard');
            span.setAttribute('data-duration', '2500');
            GlideUI.get().fire(new GlideUINotification({
                xml: span
            }));
        }

Worked fine.