Pass Input Value to server side on a widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2023 06:07 PM
Hello,
I have this html input here:
<div id="section-reprogramacao" ng-if="data.isProgFeriasCase">
<div>
<label for="changeVacationInput"> Data inicial para reprogramação de férias </label><br>
<input id = "changeVacationInput" type="textarea" href="javascript:void(0)" >
<button class="btn btn-primary" ng-click="changeVacationDay()"> Reprogramar Férias </button>
</div>
</div>
This is what I have in the client controller:
$scope.changeVacationDay = function() {
$scope.data.action = "changeVacationDay";
$scope.server.update();
};
and server script:
if (input && input.action == 'changeVacationDay') {
var value = '24-04-1995'
var grCaseTR = gr.sysapproval.getRefRecord();
grCaseTR.u_ferias_reprogramadas_por_gestor = true;
grCaseTR.u_data_inicial_ferias = value;
if (grCaseTR.update()) {
gs.addInfoMessage("Férias reprogramadas com sucesso");
} else {
gs.addInfoMessage("Erro ao reprogramar férias");
}
return;
}
This is actually working good, the only missing piece would be the value on the input that Im not being able to capture. You can note that Im using a hardcoded value as date there ("24-04-1995").
What I need this button to do is to call a function that will get the input on the textarea and pass it to the server side so I can update the record with the populate value.
Any help would be very much appreciated. Thanks,
Vini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2023 10:45 PM
Hello @Vinicius Luz1
Plz find the below link similar to your query. Refer the code and execute.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 05:57 AM - edited 10-19-2023 05:59 AM
Hi @Vinicius Luz1 , try this
<div id="section-reprogramacao" ng-if="data.isProgFeriasCase">
<div>
<label for="changeVacationInput"> Data inicial para reprogramação de férias </label><br>
<input type="text" class="form-control" uib-datepicker-popup ng-model="c.vacationDay" datepicker-options="c.dateOptions" ng-required="true" close-text="Close" />
<button class="btn btn-primary" ng-click="changeVacationDay()"> Reprogramar Férias </button>
</div>
</div>
Client:
$scope.changeVacationDay = function() {
$scope.data.action = "changeVacationDay";
$scope.data.vacationDay = c.vacationDay
$scope.server.update();
};
Server:
if (input && input.action == 'changeVacationDay') {
var value = input.vacationDay
var grCaseTR = gr.sysapproval.getRefRecord();
grCaseTR.u_ferias_reprogramadas_por_gestor = true;
grCaseTR.u_data_inicial_ferias = value;
if (grCaseTR.update()) {
gs.addInfoMessage("Férias reprogramadas com sucesso");
} else {
gs.addInfoMessage("Erro ao reprogramar férias");
}
return;
}
If my answer helped you, please mark my answer as helpful.
Vanderlei Catione Junior | LinkedIn
Senior ServicePortal Developer / TechLead at The Cloud People
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 06:00 AM
Vi que você fala português, caso queira, pode me dar um toque