Onchange client script - select box variable

J_31
Kilo Sage

J_31_0-1701230035454.png

I want to create a onchange catalog client script for State/Market variable.

 

if the value of state/market is choosen as "texas" and value of Do you need to set it up as is  "standard_tx"

 

I need to add option to care manager type/skills variable. 

 

I created a onchange client script for variable - state/market , but its not working:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    if ((newValue == 'texas') && (g_form.getValue("do_you_need_to_be_set_up_as") == "standard_tx")) {
       
        g_form.addOption('care_mgr_type', 'bx', "bexardemo");

    }
    //Type appropriate comment here, and begin script below

}

 

10 REPLIES 10

In the variable of on change client script form - which field should I set ? State/market or do you need to set up as? Earlier I kept state/market..

Hi @J_31 ,

 

You need to create 2 on Change scripts & copy paste the same script provided by @AshishKM in both. It should work fine.

 

Thanks,

Danish

 

@Danish Bhairag2 @AshishKM 

the above script worked when I changed the onchange variable, thanks so much 

 

But my requirement is even more, I actually need to populate Primary working county, Product and service based on one selection. I have attached the document. 

 

I am thinking to create and achieve using client script. Hope I am correct or should I do using any other way like script inclue. 

 

 

 

 

--------------------

 

Full Name of User: (Field - to choose CN#/name)

State/Market: (Field - Selection)

  • Florida
  • Iowa
  • New Mexico
  • North Carolina
  • Ohio
  • Pennsylvania
  • Texas

Select Role: (Field - Selection)

  • Click - Care Manager
  • Click - Program Coordinator
  • Click - Supervisor of Care Manager
  • Click - Supervisor of Program Coordinator

 

 

IF Entitlement/Role IN (Click - Program Coordinator, Click - Supervisor of Care Manager, 

Click - Supervisor of Program Coordinator and State/Market = TX

THEN

            Do you need to be set up as:

  • Standard TX
  • TX Star Health
  • Both

 

 

IF Entitlement/Role = Click - Care Manager

THEN

Provide home address:

Street:

City:

State:

Postal Code:

 

Care Manager Type/Skills: (Field - Selection)

  • ASR
  • CC
  • CM
  • ENG
  • LVN
  • RN

 

 

      IF State/Market = TX

THEN

Do you need to be set up as: (Field - Selection)

  • Standard TX
  • TX Star Health

 

IF Set Up IN (Standard TX)

THEN

 

      Primary working county: (Field - Selection)

  • Bexar

            Product: (Field - Selection)

  • Bexar-DSNP

                        Service: (Field - Selection)

  • Bexar-DSNP

            Product: (Field - Selection)

  • Bexar-MMP

                        Service: (Field - Selection)

  • Bexar-MMPL1
  • Bexar-MMPL2
  • Bexar-MMPNF

            Product: (Field - Selection)

  • Bexar-S+P

                        Service: (Field - Selection)

  • Bexar-SPL1A
  • Bexar-SPL1IDD
  • Bexar-SPL1RA
  • Bexar-SPL2
  • Bexar-SPL2IDD
  • Bexar-SPM
  • Dallas-SPNF

            Product: (Field - Selection)

  • Bexar-Star Kids

                        Service: (Field - Selection)

  • Bexar-SKA
  • Bexar-SKBH
  • Bexar-SKIDD
  • Bexar-SKL1RA
  • Bexar-SKL2RA
  • Bexar-SKNF
  • Dallas

            Product: (Field - Selection)

  • Dallas-DSNP

                        Service: (Field - Selection)

  • Dallas-DSNP

            Product: (Field - Selection)

  • Dallas-MMP

                        Service: (Field - Selection)

  • Dallas-MMPL1
  • Dallas-MMPL2
  • Dallas-MMPNF

            Product: (Field - Selection)

  • Dallas-S+P

                        Service: (Field - Selection)

  • Dallas-SPL1A
  • Dallas-SPL1IDD
  • Dallas-SPL1RA
  • Dallas-SPL2
  • Dallas-SPL2IDD
  • Dallas-SPM
  • Dallas-SPNF

            Product: (Field - Selection)

  • Dallas-Star Kids

                        Service: (Field - Selection)

  • Dallas-SKA
  • Dallas-SKBH
  • Dallas-SKIDD
  • Dallas-SKL1RA
  • Dallas-SKL2RA
  • Dallas-SKNF

El Paso

            Product: (Field - Selection)

  • El Paso-Star Kids

                        Service: (Field - Selection)

  • El Paso-SKA
  • El Paso-SKBH
  • El Paso-SKIDD
  • El Paso-SKL1RA
  • El Paso-SKL2RA
  • El Paso-SKNF
  • Hidalgo

            Product: (Field - Selection)

  • Hidalgo-DSNP

      Service: (Field - Selection)

  • Hidalgo-DSNP

            Product: (Field - Selection)

  • Hidalgo-MMP

      Service: (Field - Selection)

  • Hidalgo-MMPL1
  • Hidalgo-MMPL2
  • Hidalgo-MMPNF

Product: (Field - Selection)

  • Hidalgo-S+P

      Service: (Field - Selection)

  • Hidalgo-SPL1A
    • Hidalgo-SPL1IDD
    • Hidalgo-SPL1RA
    • Hidalgo-SPL2
    • Hidalgo-SPL2IDD
    • Hidalgo-SPM
    • Hidalgo-SPNF

Product: (Field - Selection)

  • Hidalgo-Star Kids

      Service: (Field - Selection)

  • Hidalgo-SKA
    • Hidalgo-SKBH
    • Hidalgo-SKIDD
    • Hidalgo-SKL1RA
    • Hidalgo-SKL2RA
    • Hidalgo-SPNF

IF State/Market = FL SMI

THEN

                        Primary working county: (Field - Selection)

  • FL SMI

Product: (Field - Selection)

  • FL SMI

Service: (Field - Selection)

  • Region 1-FL SMI
  • Region 10-FL SMI
  • Region 11-FL SMI
  • Region 2A-FL SMI
  • Region 2B-FL SMI
  • Region 3-FL SMI

    IF Set Up IN (TX Star Health)

    THEN

         

    Primary working county: (Field - Selection)

    • Austin-SH

    Product: (Field - Selection)

    • Austin-SH

          Service: (Field - Selection)

    • Austin-SHBHL1
      • Austin-SHBHL2
      • Austin-SHL1
      • Austin-SHL2
      • Austin-SHL3
    • Corpus Christi-SH

    Product: (Field - Selection)

    • Corpus Christi-SH

          Service: (Field - Selection)

    • Corpus Christi-SHBHL1
      • Corpus Christi-SHBHL2
      • Corpus Christi-SHL1
      • Corpus Christi-SHL2
    Corpus Christi-SHL3

J_31_0-1701535250861.pngJ_31_1-1701535265136.png

 

@J_31 ,

Based on same onChange script code you can continue to set other field value on same way.

you know the g_form.setValue() method for string value and g_form.addOption() for select type value.

 

Note: When a top field is driving the all other fields then on every change in that the rest of field should also change accordingly and make all fields empty when top one changed to "--None--".

 

-Thanks,

AshishKMishra


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Sorry to ask you much,

if you dont mind can you help me with a sample code, I will do the rest, I am trying to crack but its not working. Millionthanks in advance for help