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 

I have tired your suggestion code and it works in side of the application. However, I tried on the portal and that did not work.  I might have screwed up somewhere in the code.  Thank you for continuing to help.

 

LisaGoldman_0-1709679120587.png

 

@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

Hello @Harsh Vardhan 

You have done it again!  It works perfectly. 

I have seen many of your resolved threads, and you are truly an outstanding programmer.  

I wanted to thank you for the time and effort you have dedicated to the community.  You have really made a difference.   I sincerely thank you again.

Glad my answer helped you. 

Thank you.

This solution worked great in the classic catalog ui, but would not work in portal for me.

 

The following was the only solution i found that worked in both UIs:

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