How call server code from client controller in widget from portal

lucky24
Tera Contributor

Hi Team,

I am working on esc portal there is one add action drop down button on RITM form like below. when I will click on Access button then one dialog will appear with  submit and cancel buttion

lucky24_0-1693483959683.png

 

lucky24_1-1693484087686.png

 

On the RITM form there is one  field called return date so when I click on submit so in return date field now date field populate and comment should update.

for that I have written code in widget but when I clicking on submit button it is not performing  any action.

Please find my code below

lucky24_2-1693484509065.png

server script

lucky24_3-1693484684409.png

Client controller  ---

 
 
 
 
 
 
 
 
 
 
 
 var c = this;
    c.doneLoading = false;
c.instateRITM= "${RITM Reinstate Access}";
$scope.reinstateAccess = function() {
        var b = "submit return date";
        var c = "Submit";
        spModal.open({
            title: 'Access',
            message: b,
            buttons: [
 
                {
                    label: c,
                    primary: true,
                    value: "1"
                },
                {
                    label: '${Cancel}',
                    cancel: true
                }
            ],
 
 
        }).then(function() {
spAriaUtil.sendLiveMessage(c.instateRITM);
}, function() {
alert("cancel");
});
$scope.data.action = 'instateAccess';
    };

 

Please help me here when I click on submit  button return data should populate with today date and comment should update.

Thanks

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@lucky24 

are you able to pass control to server ?

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Jonathan Ting
Tera Guru

You can use the c.server.get function from the client which will call the server script, you just want to make sure you define your action, otherwise it will run the whole server script.

 

This article explains it more - Get server data in widget client controller - ServiceNow Community