46
Views
11
Comments
Solved
clicking two buttons using javascript
Application Type
Traditional Web

I am having two web blocks in one screen. Both of them contain lists. Using a save button in the screen, I want to save both lists.

I created two hidden buttons in both web blocks and used 'RunJavaScript' to click on the buttons using the "$.Class.click()" function. But only one of the flow is getting executed.

I tried using two separate classes and two javascripts in the save action, but then only first one gets executed.

Please help on how do I solve this? 

2024-09-09 08-44-46
BHUPENDRA SINGH
Solution
2024-09-09 08-44-46
BHUPENDRA SINGH

Hi Aastha,

Try setting class "hidden" instead of setting visible property as "False" on buttons in both web blocks and then call both buttons click event using common/dummy class name assigned to them as below from Outer Button Click handler.

document.getElementsByClassName($parameters.btncss)[0].click();

document.getElementsByClassName($parameters.btncss)[1].click();

Also set "Is Form Default" to "No" for both the buttons if they are inside form.

Hope this would help.

2024-09-09 08-44-46
BHUPENDRA SINGH
UserImage.jpg
Aastha Luthra

Hi Bhupendra, can you please share the oml for this? demo link is only the web link, i can't see the code without oml

2024-09-09 08-44-46
BHUPENDRA SINGH
Solution
DemoReactive.oml
UserImage.jpg
Aastha Luthra
2023-08-18 10-40-36
Deepak M

Hi Aastha Luthra,

Instead of calling Js, you can simply pass the list values via Events of the each blocks,

Then you can handle it in the screen and you can pass the value into the save action with the help of assigned local list.

For more details, look into the attached oml file FYR ( I did this in Reactive, you can follow the same to implement in Traditional)

Save two list.oml
UserImage.jpg
Aastha Luthra

Hi Deepak, thanks for the advice, but I have multiple validations before saving the list so would it not get complicated?

2023-08-18 10-40-36
Deepak M

No, it won't be complicated you can handle with two different handlers to avoid confusions and hidden issues

UserImage.jpg
Aastha Luthra
2023-08-18 10-40-36
Deepak M

Your welcome, If the issue is fixed, please hit the mark as solution.

UserImage.jpg
Aastha Luthra

actually i did not need to try this one, the first solution worked so i marked it as solution 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.