Question

Trying to refer to a clipboard property in a js , but not working
I am trying to refer to a clipboard property in a js file like below -
function launchSDP()
{
var e1 = tools.findPage("Clipboardpage").getProperty("propertyname").toString();
if(e1=="error" )
{ pega.u.d.reloadsection("current");
}
else
{ launch a harness;
}
}
[ what am trying to do is - if var e1 ="error" then reload the section, otherwise launch a harness ]
The error lies with the first step for loading the var e1 . Maybe am doing this in incorrect way. Can anyone tell me what would be a correct way?
***Updated by moderator: Lochan to update Categories***
-
Like (0)
-
Accepted Solution
Hi Abdul,
Just an update - I got the the clipboard value by setting that value to a hidden text control in my section and included var a = $('.keyclipb div div span').text(); in the script.
The keyclipb is the read/write class that we give in the advanced presentation option of the control.
Thanks a lot for your inputs.

Use the following syntax. Basically you are trying to access data via java api. You need to use scriplet tags like below.
var e1 = '<%= tools.findPage("Clipboardpage").getString("propertyname") %>';
Let us know if this helps.
Hi Rawap,
var e1 = '<%= tools.findPage("Clipboardpage").getString("propertyname") %>'; is correct syntax-wise but the value of e1 is not seetting as expected.
Have set an alert now to see what value is e1 holding and found it as - <%=tools.findPage("pyPortal").getString("posterrorkey").getStringValue()%>
instead of value from clipboard.
Can you please help on this.

Syntax seems to be correct here now. Just a silly question, Did you write the code or copy/pasted from here.
Sometimes copy/pasting might result in different format and would not take it as correct syntax.

Initially I had copy/pasted and modified the variables. Now I have writted the code and still it shows the same thing.

Is there anything to be defined or any files to be included so that it understands '<%=tools.findPage("pyPortal").getString("posterrorkey")%>' is not a text?
Hi Pankaj,
Any suggestions would be helpful. Thanks

Syntax wise everything seems to be fine. Where exactly are you placing this code. Scriplet code will work inside JSP. Please share where are you using this code.

Am calling the script from a button action of onClick event.
There is a Run DataTransfrom to call the service page and in its response dt , the mentioned variable(pyPortal.posterrorkey) is being set. The next action is the Run Script.
The code -
function launchSDP()
{
var e1 ='<%=tools.findPage("pyPortal").getString("posterrorkey") %>';
alert(e1);
if(e1=="error")
{
pega.u.d.reloadSection(pega.u.d.getSectionByName("DisplayConfirmationMsg","",""));
alert("reload");
}
else
{
pega.desktop.showHarnessWrapper( "current","Data-Portal","PanelContentHarness","","","pyPortalHarness","Yes","","Yes","",":event","","","","","","false");
alert("launch");
}
}
The functionality of the code is to check the posterrorkey value and either launch a harness/refresh section .

Hi AparnaG8,
You were missing a dot(.) here var e1 ='<%=tools.findPage("pyPortal").getString(".posterrorkey") %>';
I have tried it practically and posted the solution, please try it, and let me know.
If still not getting, in pages and classes of the section specify the pyPortal and its class.
Attaching the screen shots of the HTML and JS code and the alert messages.
Hopes it helps
Thanks
Abdul Razi
Hi Abdul,
Thanks for your response.
I had tried this earlier but found the same issue. Please find attached the screenshot of the alert(e1);
PS : This code is in TextFile with extension as .js

Can you please share a screen shot, how you are including the .js file and where you are inserting the scriplet to get the value from clipboard and how the function is being invoked.
Hi Abdul ,
Please find attached the screenflow.

Hi Aparna,
We cannot include a scriplet or an expression tag directly in a .js file, it works for only .jsp file at JSP compiler does the remaining work.
Trying for the solution, will let you know once i found that.
Thanks
Abdul Razi
It would be really helpful if you can find something on this.

Hi,
If you can write an additional activity to call it from JS function using the javascript which returns the out param from the activity as your required property value and then check the condition and perform the action steps as required.
For your reference, I have attached the example.
Let me know if it helps.
Accepted Solution
Hi Abdul,
Just an update - I got the the clipboard value by setting that value to a hidden text control in my section and included var a = $('.keyclipb div div span').text(); in the script.
The keyclipb is the read/write class that we give in the advanced presentation option of the control.
Thanks a lot for your inputs.