We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Calling Server side script from Client side in Service Portal

vijay39
Giga Expert

HI Guys,

Good Afternoon.

I have created my basic SP widget. In that i have created a button named "Proceed". Once i click that button, then a request must be created in service-now. Here is the code i have written in server side. How to call this in client side? Can someone help me with code? 

My widget Script is...

find_real_file.png

3 REPLIES 3

Jyoti8
Kilo Guru

Harish KM
Kilo Patron

Check this link 

https://serviceportal.io/create-custom-action-buttons-service-portal/

Regards
Harish

Not applicable

//HTML

 

<input type="submit" ng-click="onclickofProceed()" value="Proceed">

 

//CLIENT SCRIPT

 

function($scope) {
/* widget controller */
var c = this;
$scope.onclickofProceed= function(){
    c.server.update().then(function(){
                                                    
            c.data.action='proceed'
                                                    
                                                     })




};



}

 

//SERVER SCRIPT

 

(function() {

if(input.action =='proceed'){

var gr = new GlideRecord('incident');

gr.initialize();

//gr.requested_for = gs.getUserID();

//gr.short_description = "Order for desktop"

gr.insert();
gs.addInfoMessage(gr.number)

}


})();

 

please mark helpful/correct  if that helped.

Thanks.