How to get the value of a Dropdown on a widget to a field on the table
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 07:03 AM - edited 07-27-2023 09:32 AM
Im trying to get the value of a dropdown that is in a widget to the "Assign to" of a table but Im not sure how to get that value.
Code:
Widget HTML :
<div class="panel panel-default">
<div class="panel-heading">Atribuir a</div>
<div class="panel-body">
<sn-record-picker id="assigned-to"
field="c.AssignedTo"
table="'sys_user'"
display-field="c.data.reqForDispCol"
display-fields="c.data.reqForDispCols"
value-field="'sys_id'"
search-fields="c.data.reqForSearchCols"
default-query="c.data.reqForQuery"
page-size="100"
options="{allowClear : false}"
</sn-record-picker>
<br>
<button type="button" class="btn btn-default btn-block" ng-click="c.uiAction('assign_to')">Assign to</button>
</div>
</div>
Server Script:
(function() {
// Get table & sys_id
data.table = $sp.getParameter("table");
data.sys_id = $sp.getParameter("sys_id");
// Valid GlideRecord
gr = new GlideRecord(data.table);
if (!gr.isValid())
return;
// Valid sys_id
if (!gr.get(data.sys_id))
return;
data.state = gr.getValue('Assigned To');
if (input && input.action) {
var action = input.action;
if (action == 'assign_to') {
gr.setValue('assigned_to', assign_to);
gr.update();
}
}
})();
Client Controller:
api.controller = function() {
var c = this;
c.action = function(assigned_to) {
c.data.assigned_to = assigned_to;
};
c.uiAction = function(action) {
c.data.action = action;
c.server.update().then(function() {
c.data.action = undefined;
});
};
};
Dropdown on portal:
Error that I get in the portal:
0 REPLIES 0