Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

need help passing data into a modal client and server scripts

Thomas Miles
Tera Contributor

I have a model that would run on the incident table and when the use clicks this modal it woul dchange the incident state and add a comment as to why its  being changed

CLIENT

c.onOpen = function() {
                //ask the user for a string
        spModal.open({
            title: 'Change Incident status',
            message: 'Why would you like to Change the status?',
                      
            buttons: [
                {label:'✘ ${No}', cancel: true},
                {label:'✔ ${Yes}', primary: true}
            ]
                    
                      input: true,
            value: c.name
                        
        }).then(function() {
            c.name = name;
        })

 

SERVER

 

 if (input && input.action) {
 var action = input.action;
  
 if (action == 'true') {
 // Resolve Tier 1 Scorecard
     var changeStatus = new GlideRecord('incident');
     cancelStatus.addQuery('sys_id',data.task);
     cancelStatus.query();
     while(cancelStatus.next()){
         
         cancelStatus.setValue('state', ' Where the client code comes in ');
         cancelScore.update();
     }
     
     

First i and not sure how to trigger the server side code , and how to pass the data entered into the modal back to the  server so , and also how to add the incident fields to the modal.

1 REPLY 1

patricklatella
Mega Sage

Hi Thomas,

take a look at this article I posted and review the script...this may help you.

https://community.servicenow.com/community?id=community_article&sys_id=ae61924cdbf51090190dfb24399619ef