Problem with RunJavaScript action

Problem with RunJavaScript action

  
Hello,

I am using RunJavaScript function to run JavaScript code.

I am using this function to click a hidden link but when call comes to this function, Javascript associated with that function doesn't work.



I have created hidden link and on properties pane have given property like this:



and then calling this link through RunJavaScript function.

As per the functionality, when RunJavaScript function called, this JavaScript code must be executed but it's not working.

Am I doing anything wrong?

Please advice.

Thanks and Regards,
Suraj Borade
Hi Suraj,

What are you trying to achieve business wise?

What you are attempting to do architectually is frowned upon in my experience of web architecture. The server should not instigate physical events on the client. You can but it is not encouraged.

Why can you not intiate the save with logic server side?

RunJavascript will queue a script to be executed after the page is loaded in the client will mean your update action will be called first before the script runs is my guess

Regards, George

Hi Suraj,

Note that you are trying to click on the "Text" not on the "Link".


Regards,
João Rosado
nice catch João.
Hi Joao and George,

Thanks for your replies.

@Joao,
CSP team has demonstrated this technique to me in our CSP Session last week. OML which CSP team has sent to me is working fine when text inside link is named as "ClickToSave" and this link is also getting clicked when clicked through RunJavaScript function.

Only thing is that CSP team is calling this JavaScript function inside onchange event of ComboBox and I am trying to call this JavaScript function on Save button.

@George
Why can you not intiate the save with logic server side?
I have WebScreen and inside that I am using WebBlock. I want to initiate Save action inside Web Block when Save action from Web Screen is clicked and I am trying to achieve that by clicking on hidden link through JavaScript.
Note: This hidden link is inside WebBlock and Save action is associated with that link. So when JavaScript runs, it should click that link.

Please advice.

Thanks and Regards,
Suraj Borade

I have demonstrated this to CSP team yesterday and they are also thinking why this is not working in this case.
Solution
Hi Suraj,

Is your Save button maked as "Submit" or "Ajax Submit" ?
It will only work on the ajax one.

Regards,
João Rosado
Solution

Hi Joao,

It worked when I marked my Save link to "Ajax Submit".

Thanks and Regards,

Suraj Borade