UIAction to copy form details to clipboard

Andrew Bettcher
Kilo Sage

Hello,

This took me a while to sort out and I had to mix information from several locations so thought I would post in case anyone else needs to do something like this.

We use the demand form to allow our sales team to register a requirement to our pre-sales team. Once the work is accepted they wanted to be able to copy some of the details to a clipboard in order to create a calendar entry in Outlook. I looked at iCal invites via notifications and they work for the most part but they said it would be better if they could simple copy the main details to the clipboard.

Sounds easy right? I started off basic simply using g_form.getValue but got some weird results because some of the fields are reference fields and the UIAction is client side. In one version of my script, no matter what field I specified, It brought back the entry from "short_description". Very weird.

In the end, I deleted everything and started from scratch and ended up with this:

UI Action

Form Button = True

Client = True

Onclick = runClientCode();

function runClientCode(){
	
	var comp = g_form.getDisplayBox('company').value;
	var newComp = g_form.getValue('u_new_company_name');
	var number = g_form.getValue('number');
	var short_text = g_form.getValue('short_description');
	var type = g_form.getValue('u_choice_engagement_type');
	var date = g_form.getValue('u_initial_engagement_date');
	copyToClipboard('Number: ' + number + '\n' + 'Company: ' + comp + newComp + '\n' + 'Requirement: ' + short_text + '\n' + 'Engagement Type: ' + type + '\n' + 'Engagement Date: ' + date);

}

The bit that caused the problem was getDisplayBox. I came across this as I was starting to look at calling a UI page and spending a few days learning how to code UI pages and/or learning how to use GlideAjax properly.

This saved all that and works a treat. The copyToClipboard function includes a info message that tells users that details have been copied to the clipboard.

I hope this helps.

As always, if you noticed anything fundamentally wrong with the above then I'd be happy to learn what it is. 

 

1 ACCEPTED SOLUTION

Vivek Verma
Mega Sage
Mega Sage

Hi Andrew,

 

Hope you are doing well,

 

I have created article for the same.

please follow the Article. And I have attached the XMLs in case if you want deploy it your Personal Developer instance and get help from that.

 

Article Link

 

Please mark this as answered and close the thread.

View solution in original post

2 REPLIES 2

Vivek Verma
Mega Sage
Mega Sage

Hi Andrew,

 

Hope you are doing well,

 

I have created article for the same.

please follow the Article. And I have attached the XMLs in case if you want deploy it your Personal Developer instance and get help from that.

 

Article Link

 

Please mark this as answered and close the thread.

Hi Vivek,

 

That is excellent. I have a few areas where that will come in very useful.

Thank you.