Field to show based on keywords typed in another field

RohanDS
Tera Contributor

Hello team,

 

I have a requirement where I need to populate a field based on the keywords typed in another field. 

Eg:

The form has a field titled "Name of security group"

RohanDS_0-1727117406612.png

If the user types in anything that begins with or contains "KRA.", it will show another field to the user titled "Please select the group to be added into the new group".

 

Is this possible using onChange scripting?

 

2 ACCEPTED SOLUTIONS

HIROSHI SATOH
Mega Sage

For example, in the client script "OnChange"

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   //Type appropriate comment here, and begin script below
    if (newValue.includes('KRA.')) {
        g_form.setVisible('Your display field', true);
    } else {
        g_form.setVisible('Your display field', false);
    }
}

 

View solution in original post

Animesh Das2
Mega Sage

Hi @Rohan ,

Yes onChange client script should will work but please ensure that when you hide the field 'Please select the group to be added into the new group' if the 'KRA' is removed then make 'Please select the group to be added into the new group' field non-mandatory before (in case, it is set to mandatory when visible).

 

If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das

View solution in original post

2 REPLIES 2

HIROSHI SATOH
Mega Sage

For example, in the client script "OnChange"

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   //Type appropriate comment here, and begin script below
    if (newValue.includes('KRA.')) {
        g_form.setVisible('Your display field', true);
    } else {
        g_form.setVisible('Your display field', false);
    }
}

 

Animesh Das2
Mega Sage

Hi @Rohan ,

Yes onChange client script should will work but please ensure that when you hide the field 'Please select the group to be added into the new group' if the 'KRA' is removed then make 'Please select the group to be added into the new group' field non-mandatory before (in case, it is set to mandatory when visible).

 

If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.

You may mark this helpful as well if it helps you.

Thanks, 

Animesh Das