How to get the current action name of the form through server script in widget in service portal?

Yesh
Tera Contributor

Hi Team,

How to get the current action name of the form through server script in widget in service portal?

Thanks,

Yesh

6 REPLIES 6

Sagar Pagar
Tera Patron

Hi,

Have you tried by input.action in server script.

 

if(input  && input.action == 'action_name'){

// add script here

}

 

Thanks,

Sagar Pagar

The world works with ServiceNow

Yesh
Tera Contributor

Hi @Sagar pagar ,

Yes, I have tried that. I am getting action is undefined.

Thanks, 

Yesh

Hi,

you have to define that action in server side script and in client side.

 

for example- I have created it for create new incidents

Server script:   

data.newIncident = {
        issueName: '',
        urgency: ''
    }

    if(input && input.action === 'createIncident'){
        createIncident(input.newIncident);
    }

 

    function createIncident(inc){

// create incident script


    }

 

Client controller:

api.controller=function() {
  /* widget controller */
  var c = this;

      c.data.action = 'createIncident';  // action name

};

 

Thanks,
Sagar Pagar

 

The world works with ServiceNow

Yesh
Tera Contributor

Hi @Sagar Pagar ,

It is still getting as undefined.

Thanks,

Yesh