Run Script on dropdown change

Hey all I am trying to run a javascript when the user selects a particular option.

I have created a text file by going to Create → Technical → Text File

Once I am there I fill out the needed info:

Then I click on Create And Open:

And so I save that and go back to my layout where I am wanting to call it from the dropdown:

So as you can see I am doing a Run Script which I call the reqOnOrOff (I also tried just having yo) when the user selects the item called Tunable FFL.

Once that is saved I go view that page in pega itself and open up the console (F12) and refresh the page and then select Tunable FFL from the dropdown and there is no console text saying “hello” as there should be.

The overall goal is to be able to dynamically change a textbox required properties on (it required to fill out) or off (it is not required to fill out).

Anyone that can help me fix this (or tell me what I am doing wrong) would be great!

Thanks

Edited by Moderator Marissa to update Platform Capability tags*

Hi David,

I found two issues with this implementation.

  1. Please ensure that the JS text file is included in the "script & style" tab of the particular harness rule.
  2. Mention function name in the “Run Script” field. Example yo in this context.

Suggestion : You can remove action when conditions to check whether the function is triggered for the first time and then you can place it.

After this, I guess you can able to get a log message in the console. Good Luck

Thank you for taking the time to help me out and so quickly, duraisankar!

I do not seem to have an option of script & style?

I have changed it to “yo” and it still seems not to show up in the console.

Hi David,

You will not find an option to include js files in section rule.

You can reference your script file in the harness from which this section is called you can use referencing rules option from the action dropdown if you are not sure about the harness name.

So I finally found a tutorial to show me how to create a harness but it still seems to not be working?

Hi David,

Is the section you are using to call the script lies in the same harness where you included the script file?

A harness is the top level container to hold sections

So make sure you call your section"choose workbasket" from “requiredonoroffharness”

Or you can click on action button in top toolbar of your section rule. And you can see view references link .click on it and it will open a new window showing type of rules and their names and places they are used .

You can use that navigation to find the harness .

Hope this helps