Question
Last activity: 19 Mar 2018 13:54 EDT
Copy property value in clipboard to variable using JavaScript
Hi Team,
I have tried the below code to copy property value in clipboard to variable using JavaScript but it didn't work.
Code:
var e1 = '<%= tools.findPage("Clipboardpage").getString("propertyname") %>';
alert(e1);
PFA for reference.


Pegasystems Inc.
IN
Hi Durga,
Thanks for your reply.
I have written this code in text rule(.js) and I called it in action set of button(On click-Run Script).It's not working.Could you please let me know whether I am following the correct approach or not to copy clipboard property value to variable using java script.
PFA for reference.
Hello Chinna,
Refer below example.
var value = "<pega:reference name="OperatorID.pxInsName" mode="normal"/>";
alert(value);
Cheers,
Tharinda
Hi Tharinda,
Getting the error message "Parsing error: Unexpected token OperatorID". PFA.
Thanks,
Chinna
Try using single quotes inside JSP tag
var value = "<pega:reference name='OperatorID.pxInsName' mode='normal'/>";
Also you should write this inside a function.
Ex: function getValue(){
var value = "<pega:reference name='OperatorID.pxInsName' mode='normal'/>";
alert(value);
}
When calling the script from button use the function name.
In your scenario, use "getValue" (function name) instead of "CopyClipboardData"
Hi Tharinda,
As you suggested I have given the function name in action set(Run Script) but alert message is not displaying.PFA.
Thanks
Chinna
Did you include the JS file in the harness rule? If its not, your script will not be available in DOM.
Hi Tharinda,
I am able to see the alert message but it is not copying clipboard data.PFA.
Thanks
Chinna
Accepted Solution
Try including the script in a label control in your section.
Add a label control to the section. Include the function in the label value inside script tags.
<script>function getValue(){var value = "<pega:reference name='OperatorID.pxInsName' mode='normal'/>"; alert(value);}</script>
Hello Chinna,
Thanks for posting queries in PSC.
Can you try with the below code and let us know the outcome.
var e1 = '<%= tools.findPage("Clipboardpage").getProperty("propertyname") %>';
Thanks & Regards,
Durga