Question
Mindtree Ltd
IN
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.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
EvonSys
US
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>
Pegasystems Inc.
IN
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
Mindtree Ltd
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.
EvonSys
US
Hello Chinna,
Refer below example.
var value = "<pega:reference name="OperatorID.pxInsName" mode="normal"/>";
alert(value);
Cheers,
Tharinda
Mindtree Ltd
IN
Hi Tharinda,
Getting the error message "Parsing error: Unexpected token OperatorID". PFA.
Thanks,
Chinna
EvonSys
US
Try using single quotes inside JSP tag
var value = "<pega:reference name='OperatorID.pxInsName' mode='normal'/>";
EvonSys
US
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"
Mindtree Ltd
IN
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
EvonSys
US
Did you include the JS file in the harness rule? If its not, your script will not be available in DOM.
Mindtree Ltd
IN
Hi Tharinda,
I am able to see the alert message but it is not copying clipboard data.PFA.
Thanks
Chinna
Accepted Solution
EvonSys
US
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>
-
Jagadish Muktapuram