This topic is locked
[SOLVED]

Javascript Use In Spreadsheet Mode

9/27/2022 4:20:16 PM
PHPRunner General questions
C
copper21 author

Hello All,

I have a list page that is set to spreadsheet mode that adds the record automatically. This works great. I am looking to make a field mandatory based on the selection made in a radio button field (Edit As: List of Static Values). I have the field "PassFail" that has 3 radio buttons, Pass, Fail, Undetermined. If the user selects "Fail" I would like another field "Actual Results" (varchar (100)) to be mandatory.

I have used the below code in other projects and it works great. Do I need to do something different because I have enabled spreadsheet mode with automatic adding of record?

var PassFail = Runner.getControl(pageid, 'PassFail');
var AcutalResult = Runner.getControl(pageid, 'ActualResults');

PassFail.on('change', function(e){
if (this.getValue() == 'Fail'){
AcutalResult.addValidation('IsRequired');
}else{
AcutalResult.removeValidation('IsRequired');
}
});
Admin 9/27/2022

The general idea of the code looks correct.

  1. Where do you add this code?


  2. What exactly doesn't work?



C
copper21 author 9/27/2022

I am using it on the Javascript on the edit in events. I did also try it on the Javascript on the list page on the event page.

For example in the image. The user selects "Fail" on the first line of data (Step 1). The user then goes to the next line (Step 2) to fill out that row of data. I want the user to be notified that they need to leave a remark in the "Acutal Results" field (Step 1) on the line they marked "Fail".

img alt

Admin 9/27/2022

What is "Javascript on the edit in events"? Maybe show us a screenshot (full-page, not cropped) that explains where exactly this code is added?

C
copper21 author 9/28/2022

Events Page, Test Plan Steps, edit page, JavaScript OnLoad

img alt

Admin 9/28/2022

Thank you!

Just double-checked with our developers and it appears that at the moment Edit /Add Javascript OnLoad events do not work in Spreadsheet mode. This is something that we will fix shortly.

C
copper21 author 9/28/2022

Perfect, thank you!