How do I get an html element that is is another widget ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 02:50 AM - edited 10-11-2023 01:52 AM
Hi everyone, I have a modal with a textbox, wich I want to get the value of the textbox and put it on a field.
The problem that Im having is that Im using a widget to open the modal and the "modal" widget wich has a "record-picker" and a text box. I wanted to get the value of that text box and input it on a field.
Code:
Button Code:
HTML:
<div id="AtualizarButton" class="panel panel-default">
<div class="panel-heading">${Atualizar}</div>
<div class="panel-body">
<button type="button" class="btn btn-primary btn-block" style="background-color: #3641B3;" ng-click="c.openModal()">${Atualizar}
</button>
</div>
<div class="m-t-lg wrapper">
<h3>{{c.recObject.displayValue}}</h3>
</div>
</div>
Client Controller:
api.controller=function($scope, spModal) {
var c = this;
c.recObject = {
"displayValue":"",
"name":"user",
"value":""
}
var widgetInput = {
"label": "${Selecione um utilizador}",
"table":"sys_user",
"searchFields": "name,user_id",
"displayFields": "name,user_id",
"defaultQuery": "active=true",
"valueField": "sys_id",
"pageSize": "10"
}
c.openModal = function(){
spModal.open({
widget: 'modal-record-picker',
shared: c.recObject,
widgetInput: widgetInput,
scope: $scope
}).then(function(resp){
//executes after the "ok" button is clicked
//process c.recObject data as needed here
c.server.get({
action: "ASSIGNTO",
assignee: c.recObject.value
})
})
}
};
Server Script:
(function() {
data.table = $sp.getParameter('table');
data.sys_id = $sp.getParameter('sys_id');
var gr = new GlideRecord(data.table);
if(input && input.action == 'ASSIGNTO'){
if(gr.get(data.sys_id)){
gr.assigned_to = input.assignee.toString();
gr.update();
}
}
})();
Modal Code:
HTML:
<div>
<label>{{data.label}}</label> <!-- {{data.label}} -->
<sn-record-picker field="c.recObject" table="data.table" search-fields="data.searchFields" display-fields="data.displayFields" value-field="data.valueField" default-query="data.defaultQuery" page-size="data.pageSize"> </sn-record-picker>
<br><br>
<label>Escreva uma breve descrição da alteração</label>
<br><br>
<textarea id="myTextarea" rows="10" cols="87"></textarea>
</div>
Client Controller:
api.controller=function($scope) {
var c = this;
c.recObject = $scope.widget_parameters.shared;
};
Server Script:
(function() {
if (input) {
data.label = input.label;
data.table = input.table;
data.searchFields = input.searchFields;
data.displayFields = input.displayFields;
data.defaultQuery = input.defaultQuery;
data.valueField = input.valueField;
data.pageSize = input.pageSize;
}
})();
I want to get the value of the (<textarea id="myTextarea" rows="10" cols="87"></textarea>) in the modal widget and put it on a field of a table and save all the updates (dont want it to clean the value that was on the field I just want to add the new input to the old one).
Does anyone knows how to do this ?