cancel
Showing results for 
Search instead for 
Did you mean: 

Personas 3.0 - setProperty not working for a button.

former_member238607
Participant
0 Kudos

Hi,

I'm trying to crate a toggle button, which should basically switch it's attributes back and forth when it's clicked. I've written the code below, which I believe is proper JavaScript. But the setProperty line either never executes, or else it does execute but has no effect on the button. The code is not failing, because the JavaScript continues to run past this point.

if (session.findById("wnd[0]/usr/btnPersonas_1234567890").getProperty("fontWeight") == "bold") {

  session.findById("wnd[0]/usr/btnPersonas_1234567890").setProperty("fontWeight", "null");

}else{

  session.findById("wnd[0]/usr/btnPersonas_1234567890").setProperty("fontWeight", "bold");

}

The getProperty works fine, it's just the setProperty I'm having issue with.

Any ideas on what's wrong?

Thank you very much for your help!

Accepted Solutions (0)

Answers (2)

Answers (2)

clemens_gantert
Active Participant
0 Kudos

Hello Jeff,

the following script works in my environment.

if (session.findById("wnd[0]/usr/btnPersonas_147327652951579").getProperty("fontWeight") == "bold") {

  session.findById("wnd[0]/usr/btnPersonas_147327652951579").setProperty("fontWeight", "null");

}else{

  session.findById("wnd[0]/usr/btnPersonas_147327652951579").setProperty("fontWeight", "bold");

}

Please open a CSS ticket for this so we can investigate.

Best Regards,

Clemens

SAP Screen Personas

former_member238607
Participant
0 Kudos

Hi Clemens,


I have been testing this issue various ways, and I'm seeing some very strange anomalies that I believe must be software issues. If you, or anyone else, has a few minutes, please try the following actions to see if you get the same results I am.

1) Create a new flavor (to keep it simple, it built mine on SMEN) and insert a script button.

2) Create a new script using the code below. Make sure you get the GUID for your script button and replace the ones in my script. The expected behavior is to toggle the button between a bold font with yellow background and a normal font with default background.

if (session.findById("wnd[0]/usr/btnPersonas_147333908825738").getProperty("fontWeight") == "bold") {

  session.findById("wnd[0]/usr/btnPersonas_147333908825738").setProperty("fontWeight", "null");

  session.findById("wnd[0]/usr/btnPersonas_147333908825738").setProperty("backgroundColor", "null");

}else{

  session.findById("wnd[0]/usr/btnPersonas_147333908825738").setProperty("fontWeight", "bold");

  session.findById("wnd[0]/usr/btnPersonas_147333908825738").setProperty("backgroundColor", "rgba(248,225,2,1)");

}

3) Edit your flavor and attach the script to the button's onCLick event. Save the changes and test the button. If it behaves like it does for me, the font weight will toggle between normal and bold, but the background color will not change.

4) Edit your flavor and set the button's fill color to purple (something other than yellow). Save your changes and test the button. If it behaves like mine, on the first click the background color will change to yellow, but the font weight will remain normal. Additional clicks will have no effect on the button.

5) Edit your flavor and set the button's fill color back to 'Default'. Save and test the button. If it behaves like mine, nothing happens to the button when you click it.

6) Edit your flavor and change the button's font weight to bold. Save and test the button. If it behaves like mine, the font weight will toggle between bold and normal again, but the background color won't change.

7) Edit your flavor and set the button's fill color to purple again. Save your changes and test. If it behaves like mine, the button will finally behave as expected, toggling between a bold font with yellow background and a normal font with default background.

It took me a lot of time to figure out why I was having my initial issues, and I accidentally discovered following these steps finally achieves the desired behavior.

I had one other item I noticed while working on all this. If I create a new button, go into scripting and look at the Inspector section for the button, there are a number of style properties (such as backgroundColor, borderColor, etc.) at the end of the list after the onClick line. However, if I attach a script to the button and go back to this list, onClick is the last line and all of the style properties no longer appear. I can go back and remove the onClick script from the button, and the style properties will once again appear in the list. This also seems like a software bug to me.

If you have time to follow the steps I've listed above, please let me know if you see the same behaviors. And if you are on the SAP Personas team and this is a bug, please let me know if you need any additional information.

Thank you very much for your help!

clemens_gantert
Active Participant
0 Kudos

Hello Jeff,

this is quite a comprehensive test. I did not do all the steps because my results diverged from yours from the get go. I tested on the latest publicly available 7.45 kernel and latest Personas client. However, there might be some ABAP changes in that system that will only become available with SP4.

Results:

Step 3): For me the background toggles too, from yellow to default to yellow.

Step 4): Initially, the background is purple, on button clicks the background is toggling between yellow and default (backgroundColor = null is interpreted as default background color).

Step 5): Same behavior as reported in step 3.

Even though the problem appears to be fixed in my internal SAP system, you might want to open a CSS ticket for it.

Best Regards,

Clemens

SAP Screen Personas

0 Kudos

looks ok to me, Should work.

What kernel patch are you on?

former_member238607
Participant
0 Kudos

We are on kernel 745_REL, patch level 100 and Personas 3.0, patch 3.