Unable to clear existing choice field with none by passing space or nothing

vivek dhasmana
Kilo Contributor

Hi All, I am very new to service now and stuck with a problem.

I have created a custom attribute named Team on target table and configured everything to map between source and target table.I have some value inside choice field and which i want to clear when i send blank space or leave the field as blank, The problem is the onBefore event script is not working properly i guess and when I am sending blank space,The target field is showing as the last updated field in choice list(Want to make is 'none'). Below is my onBefore event script. Any help is highlty appreciated.

 

gr.query();
while (gr.next()) {
var ele = gr.element;
var val = source.getValue(ele);
if (!gs.nil(ele)) {
if (val !== " ") {
source.setValue(ele,val);
}
else {
source.setValue(ele,"NULL");
}
}
}

9 REPLIES 9

Tushar Sharma2
Kilo Guru

Hello,

What exactly you are going to achieve.

If we do not pass any thing to the choice field it consider it as a null by default. you no need to write any script for the same.

And one more thing i noticed that you are setting value "source.setValue(ele,"NULL")" means you are setting the field name as null(not value) if you gliding the sys_choice table.

Hit Helpful or Correct on the impact of response.

Regards,
Tushar
www.DxSherpa.com

 

Hi Tushar, Thanks for the reply,

 

Actually by default when I am not providing any value during update operation or just sending a blank space,The value is not being considered as null and showing the previously set value in the target table .I want to make it as null while updating if i pass space or leave the field empty.

vivek dhasmana
Kilo Contributor

Hi All,

I am still facing the problem of resetting the choice field value to none. I am not sure what value does --NONE-- contains in choice field so that I can use the same value to reset the existing selected field value to NONE. It can be done via script but not sure how.Please advise if someone knows.

Could you please elaborate the issue along with script?