cancel
Showing results for 
Search instead for 
Did you mean: 

Need Java Scripting to raise an error in adobe form

Former Member
0 Kudos

Hi,

I have a radio button group in that i have three radio buttons, by default no radio button is selected, when i execute the adobe form in portal the system should not allow me to proceed further until and unless i select any radio button. I made the radio button group property to user entered required and i have written some error message in the error tab, but this error is not triggering, do i need to write any java script if so in which event i need to write and what is the script. Any help will be greatly appreciated.

Regards,

Venkat.

Accepted Solutions (0)

Answers (3)

Answers (3)

vaibhav_tiwari
Contributor
0 Kudos

Hi Venkat,

Have you any submit button or any other event trigger UI element to execute the form. If yes then write the following script in the click event:

if( RadioButtonList.rawValue == ' ' )
    xfa.host.messageBox("Choose any Radio Button");
else
    app.eval("event.target.SAPSubmit();");

here in the else condition i have used the default code written at the click event of a web dynpro activeX submit button. If you are using the same button then the code is perfect for you else change the else condition code according to the requirement.

Hope it will be helpful.

Regards,

Vaibhav Tiwari.

krishanu_biswas
Active Participant
0 Kudos

Hello Vaibhab,

Your JS code looks absolutely fine. But, this was something that i always try to avoid. Imagine if you have 10 forms and you have the same logic to be implemented in 20 diferent event handlers, maintaining all of them over the time would become a nightmare. Instead, write your validation logic in one place in your application on the server and let all the client side events make use of it. Tommorow, if you have change in your logic, you would only do the changes in one place instead of doing it in all 10 different forms. What goes agaist with my proposal is that you end up making some server requests everytime you submit a form. But, this would be perfectly aligned with the Web Dynpro philosophy wherein every request is a server request and you do not have any provision to write any client side JavaScript in Web Dynpro. I would recommend to go for JavaScript only when you absolutely need to write it.

Best Regards,

Krish

vaibhav_tiwari
Contributor
0 Kudos

Hi Krishanu,

Thanks for sharing your knowledge. It seems useful.

Regards,

Vaibhav Tiwari.

krishanu_biswas
Active Participant
0 Kudos

Hello Vikram,

There is no way that you can stop a user submit (sending request to the server) once "Submit" is clicked/or a similar operation takes place. You might succeed in showing an alert box, but you would not be able to stop the server request. This is how Web Dynpro works.

So, the best approach to handle your scnario would be to put your validation on the server (in your application code). If a checkbox is selected, go ahead (navigate, R/3 call or do whatever your application intends to do) ELSE go back to the same view with an error message being displayed on the page, promting the user for a mandatory input for the checkbox.

Best Regards,

Krish

Former Member
0 Kudos

Hi,

This is very urgent, any body please provide inputs. Any help will be greatly appreciated.

Regards,

Venkat

Former Member
0 Kudos

Hi Venkat,

To ensure that this validation is triggered u'll need to find an event that will be fired befre a user tries to proceed.

So at that event say on click of a button, u place this script:

if(BodyPage1.Subform.RadioButtonList.isNull || BodyPage1.Subform.RadioButtonList.rawValue == "")

{

xfa.host.messageBox("Please enter value");

xfa.host.setfocus(FieldName);

}

This would not let the user proceed..

Hope this helps..

Thanks

Amita