Webblock action is not called from JS

Webblock action is not called from JS

  

Hello All,

I am facing issue while calling a webblock action which sets a value for session variable.

Usecase is:

I have a webscreen and inside that has a webblock. The Webblock has a Fileupload widget that uses OnCHANGE Javascript to validate if the file is of proper size, extension etc. I have set the button's id 

to input parameter of JS, and the button destination is set to the webblock action which updates the session value. 

Code snippet like this:

function validate(button) {....}

$('#'+button).click();

button css: display:none;

However, the screen action is not getting triggered and thus, not updating the session variable value. FYI: Submit Screen action is used.


Am I missing something? Any help is appreciated! 

Thanks.




Hi Deepti, 

Where you have written js, on screen or web block?

Simply first try to display alert message on javascript.


Thanks,

Rajat Agrawal

Hi Deepti,

You can use this piece of code to click in the button:

document.getElementById('"+button+"').click();

Hi Deepti Mehta,


Please refer the attached .oml solution if you find any difficulty in implementation.


Hidden Button Properties:

Upload Widget Properties:


Upload Widget onchange JS:

SyntaxEditor Code Snippet

"$('#" + HiddenBtn.Id + "').click();"


Note: Logic flow to Retrieve/Store (as per the requirement) the uploaded file should be written in the Hidden Button Logic flow as the Button is set to Submit on Click Method. The page gets refreshed/postback on hidden button click and the upload widget content gets empty. 

Hope it helps you!


Kind Regards,

Benjith Sam