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

James Chun
Kilo Patron

Hey @Lisa Goldman,

 

Looks like you are using the auto-populate functionality. If so, there is no need to write a client script.

Deactivate the client script and see if it works.

 

Cheers

Hi @James Chun 

I have tried deactivate the client script, but that did not work. That is the reason why I am seeking the community advice on how to handle this.  Thank you for helping.

Right, it might be because it's lookup select box type.

Can you try removing all the code after line 6 and replace it with the following:

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

Hi @James Chun 

I have tried your suggestion code and it behavior remains the same.  

LisaGoldman_0-1709669121399.png

 

I modified the type to reference and it works fine without and code, but it did not work on the look up select box type and I do not know why.