How to create a widget with dropdown field and save value to table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2020 03:13 AM
I have a table called "saving"
It has a choice field with values A, B, C
I want to create a widget with drop down field shows above value
User would select one value and On submit, the value should be saved to saving table
Please help
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2020 05:34 AM
Hi Prasad,
Check below example-
HTML-
<<select id="mySelect" ng-init="c.data.u_temp_bu.BU = c.options[0]" ng-model="c.data.fieldname" ng-options="option.name for option in options" required></select>
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" ng-model="c.data.fieldname">Select dropdown value
<span class="caret"></span></button>
Client script-
function() {
/* widget controller */
var c = this;
c.sites=[{
name:'None',
value:'None'},
{
name:'Admin',
value:'Admin'},
{
name:'User',
value:'User'}]
c.addItem = function() {
c.server.update().then(function(response){
c.data={};
})
}
}
Server script-
(function() {
if (!input)
return;
var gr = new GlideRecord('table name');
gr.initialize();
gr.dropdown_fieldname = input.dropdown_fieldname;
gr.insert();
})();
Mark correct and/or helpful if my answer has solved/helped your issue.
Thanks,
Ruhi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2020 06:31 AM
Not working, pls review below code, attachment and suggest changes
HTML
<select id="mySelect" ng-init="c.data.u_temp_bu.BU = c.options[0]" ng-model="c.data.u_benefit_to" ng-options="option.name for option in options" required>
</select>
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" ng-model="c.data.u_benefit_to">Select dropdown value
<span class="caret"></span></button>
CLIENT
function() {
/* widget controller */
var c = this;
c.sites=[{
name:'None',
value:'None'},
{
name:'Admin',
value:'Admin'},
{
name:'User',
value:'User'}]
c.addItem = function() {
c.server.update().then(function(response){
c.data={};
})
}
}
SERVER
(function() {
if (!input)
return;
var gr = new GlideRecord('u_sample_table');
gr.initialize();
gr.u_benefit_to = input.u_benefit_to;
gr.insert();
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 06:53 AM
It is not working