How to clear select lookup box variable value?

Lisa Goldman
Kilo Sage

Hello,

I have the following two variables, reference and lookup select box.  The variables are getting data from the same table: u_part_number

 

LisaGoldman_4-1709665567580.png

 

 

On the "lookup select box", I am using Auto-Populate to fill in the Part Id variable.

 

LisaGoldman_2-1709664805739.png

 

How to you clear Part Id variable on Part number changes.

LisaGoldman_5-1709665668584.png

 

 

Here is the onChange script I have tired, but it did not work.  Please help.  Thank you

 

LisaGoldman_3-1709665307797.png

 

 

 

 

1 ACCEPTED SOLUTION

@Lisa Goldman  Strange , but anyways you can give another try. 

 

Set 'Include none' as true on your Lookup select box variable and now use below script.

eg:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (newValue == '') {       
	 g_form.removeOption('part_id','');
        g_form.addOption('part_id', '', '');
    }
}

 

Thanks,

Harsh

View solution in original post

20 REPLIES 20

Harsh Vardhan
Giga Patron

@Lisa Goldman  You don't need client script to clear the value. It will auto clear it once you change the reference variable value. 

Please make sure, you have checked "Include none" in your lookup select box variable ?

 

Thanks,

Harsh

 

Hi @Harsh Vardhan 

I'm sure your suggestion will work because I have already tried.  Is it possible to leave the variable blank?  Currently, it displays "none" when left empty.  Thank you

@Lisa Goldman  no, that wont be possible, also none is empty from scripting perspective. 

May I know why are you not going with none option ? 

 

Or may be you can use single line text field to auto populate and set empty based on your need . no scripting required here. 

 

Thanks,

Harsh

@Harsh Vardhan 

I am trying to understand why it works with the reference type but not with the lookup select box type. This is for my learning purposes.  I will use the reference type instead. 

Thanks to everyone who is trying to help.

@Lisa Goldman  I tried to investigate a little bit more into my personal instance, here is my solution. please try , tested on my PDI and working.

 

function onChange(control, oldValue, newValue, isLoading) {
	if(newValue=='')
    g_form.addOption('part_id', '', '');
	

}