Populate lookup selectbox choice based on reference field

Sriharsha3
Tera Contributor

Hello ,

I have two variables Reference and lookup selectbox both referencing same table.

My requirement is: Both are referencing Business Application table. However the lookup select box field's lookup value field is  install_type

How to populate the install_type of selected application on the Select box field.

 

Eg: Application A install type is Production. So when i select Application A on the reference field, lookup field should populate with Production choice.

1 ACCEPTED SOLUTION

Hi Param,

If you still need that to be show and present then please find below suggestions

1) Since you just want to auto-populate Install Type based on application selected; please use single line text variable

2) use onchange on Reference variable to populate it

3) set it read-only from that script

Sample Client Script:

Note: Ensure you use proper variable name for

1) business name reference variable

2) install_type variable

3) install_type field from business app table

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading) {
// always set as read-only
g_form.setReadOnly('install_type', true;)

      return;
   }

//Type appropriate comment here, and begin script below

if(newValue == ''){
g_form.clearValue('install_type');
}

var ref = g_form.getReference('business_app', callBackMethod);
   
}

function callBackMethod(ref){
if(ref.install_type != ''){
g_form.setValue('install_type', ref.install_type);
}
}

Mark āœ… Correct if this solves your issue and also mark šŸ‘ Helpful if you find my response worthy based on the impact.
Thanks
Ankur

 

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

16 REPLIES 16

Hi Anurag,

 

Thanks for answering.

I'm dealing with variables of a catalog item and not on the form level.

Please suggest

Hi Param,

As said by Anurag; no need to create variables referring to same table

User can see the Install Type there itself then why to populate it again?

No need of extra variable

Mark āœ… Correct if this solves your issue and also mark šŸ‘ Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello Anurag,

 

The second variable is needed for confirmation and for viewing in Sc Task forms.

I need to populate the related column again on the select box variable.

Hi Param,

Are you saying you want only Lookup select box variable to be shown and not the Reference variable?

Any specific business requirement for this?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Anurag,

 

Both the variables are to be shown. 

Requirement is simple to show Install type in another variable based on the selected application.