Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Insert data from custom table to sys_choice

Chronos
Tera Contributor

Hi everyone,
I have a problem, when selecting data for Car Name, if I select Other, there will be a Car Name 2 field that will be opened below. After data entry and Submit, I want the data entered in Car Name 2 to be added to Car Name's Choice list.
Does anyone have any solutions?
Thanks,

Chronos_0-1678256993310.png

 

 

1 ACCEPTED SOLUTION

Hi @Chronos you can write After insert Business rule using below code

 

if(current.u_car_name2!='')

var gr = new GlideRecord('sys_choice');

gr.initialize();

gr.name ='YOUR TABLE NAME';

gr.element= u_car_name;

gr.label=current.u_car_name2;

gr.value=current.u_car_name2;

gr.insert();

 

You can also achieve this using Flow Designer and that would be recommended as it is low code.

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

 

View solution in original post

4 REPLIES 4

-O-
Kilo Patron

Have you tried creating a Flow (using Flow Designer), triggered to run on insert of whatever is involved, if the field has value Other?

Chronos
Tera Contributor

I think this can be done by writing Business Rule on Insert, but I have no idea how to do that.

Hi @Chronos you can write After insert Business rule using below code

 

if(current.u_car_name2!='')

var gr = new GlideRecord('sys_choice');

gr.initialize();

gr.name ='YOUR TABLE NAME';

gr.element= u_car_name;

gr.label=current.u_car_name2;

gr.value=current.u_car_name2;

gr.insert();

 

You can also achieve this using Flow Designer and that would be recommended as it is low code.

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

 

Hi, @priyasunku 

Thanks for guiding me in the right way, but I should fix it a bit in your code

if(current.u_car_name2!='')

var gr = new GlideRecord('sys_choice');

gr.initialize();

gr.name ='YOUR TABLE NAME';

gr.element= 'u_car_name';

gr.label=current.u_car_name2;

gr.value=current.u_car_name2;

gr.insert();