Adding a + button that creates a new choice field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 09:39 AM
Okay so I need some help with this, ill attach my UI ACTION code and a screen shot.
What I'm trying to do is add a " + " button to one of my choice fields (HAZARD) in my form or right next to it. I have a form that requires many choice fields but INSTEAD of making a gigantic form with an excessive amount of fields id like to add a " + " button next to the first field so that if an end user needs to add another field then they can just click the button and another one will appear if they need. Has anyone ever done this before? I probably need help with the script
As you can see all this code does is input a dead " + " button at the bottom.
Here is my code
function addDropdownOption() {
// Get the dropdown field
var dropdown = g_form.getControl('u_choice_2');
// Create a new option
var option = document.createElement('HAZARD');
option.text = 'New Option';
option.value = 'new_option';
// Add the new option to the dropdown field
dropdown.add(option);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 12:08 PM
I dont know if thats an option with Servicenow forms.
I would rather create another table linked to this table and provide user to create record in that using embedded list. Below is an example.
Please mark this response as correct or helpful if it assisted you with your question.