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***

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Correct Answer
December 1, 2016 - 4:16am

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.

Comments

Keep up to date on this post and subscribe to comments

Pega
November 23, 2016 - 8:02am

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.

November 23, 2016 - 12:56pm

That works! Thanks for the suggestion. 

November 25, 2016 - 2:23am

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.

Pega
November 25, 2016 - 7:05am
Response to AparnaGopakumar

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.

November 28, 2016 - 1:51am
Response to rawap

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

November 28, 2016 - 2:17am
Response to rawap

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?

November 29, 2016 - 1:38am

Hi Pankaj,

Any suggestions would be helpful. Thanks

 

Pega
November 29, 2016 - 1:44am
Response to AparnaGopakumar

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.

November 29, 2016 - 2:51am
Response to rawap

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 .

November 29, 2016 - 6:56am
Response to AparnaGopakumar

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

November 29, 2016 - 7:33am
Response to 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

November 29, 2016 - 8:28am
Response to AparnaGopakumar

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.

November 29, 2016 - 9:22am
Response to Abdul_Razi

Hi Abdul ,

Please find attached the screenflow.

November 30, 2016 - 1:28am
Response to AparnaGopakumar

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

November 30, 2016 - 12:45am
Response to Abdul_Razi

It would be really helpful if you can find something on this.

November 30, 2016 - 7:01am
Response to AparnaGopakumar

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.

 

December 1, 2016 - 4:16am
Response to Abdul_Razi

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.

December 20, 2016 - 11:47pm

Hi Aparna, 

Thanks for the reply.