Service portal: clicking on button should make record active true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 07:14 AM
Hi Experts,
I have simple list widget on left hand side and custom widget on right handside, on the selection of records which are inactive i should see a button reactivate and when clicking on it ,the input/selected record should be active true
HTML :
<button class="btn btn-primary" ng-click="c.reactivateprj()">${Reactivate}</button>
Client script :
c.reactivateprj = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'reactivate',
scope: $scope
});
// Call the server-side function to reactivate the project
c.server.reactivateprj();
Server script : function reactivateprj(input) {
var proj = new GlideRecord('table_name');
proj.addQuery('sys_id', input.sys_id);
gs.info('printvalue'+input.sys_id);
proj.query();
while (proj.next()) {
proj.active = true;
proj.update();
}
Please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 07:46 AM
Hi there,
can you please try below -
HTML
<button class="btn btn-primary" ng-click="c.reactivateprj()">${Reactivate}</button>
client script -
c.reactivateprj = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'reactivate',
scope: $scope
});
// Pass the selected record's sys_id to the server-side function
c.server.reactivateprj({ sys_id: c.data.selectedRecord.sys_id });
};
server script -
function reactivateprj(input) {
var proj = new GlideRecord('table_name');
proj.addQuery('sys_id', input.sys_id);
gs.info('printvalue' + input.sys_id);
proj.query();
if (proj.next()) {
proj.active = true;
proj.update();
}
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 08:27 AM - edited 07-24-2023 08:27 AM
Hi @Tushar ,
Thank you for you response,
tried above but no luck,
please find existing server script :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 08:37 AM
Updated one -
(function () {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
if (!input) return;
var fields = "sys_id,name,account,description";
var pjGr = new GlideRecord("prj_desc");
if (pjGr.get(input.sys_id)) {
data.record = {};
$sp.getRecordElements(data.record, pjGr, fields);
gs.info('print value of input.sys_id' + input.sys_id);
}
})();
// Define the reactivateprj function outside the IIFE
function reactivateprj(input) {
gs.info('inputvalue' + input);
var proj = new GlideRecord('prj_desc');
proj.addQuery('sys_id', input.sys_id);
gs.info('printvalue' + input.sys_id);
proj.query();
if (proj.next()) {
proj.active = true;
proj.update();
}
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 08:45 AM - edited 07-24-2023 08:47 AM
@Tushar Still the same ,its not entering the function reactivateprj()
updated client script :