when user clicks re-open button it should show a popup input box on portal.

Allu Gopal1
Giga Guru

Hi,

I have a requirement that, when user clicks re-open button it should show a popup input box on portal and ask to enter the reason for re-open of incident. But unable to find the solutions in widget to show that customized popup window using SpModal in servicenow widgets.  When user clicks Ok in pop up window it should set the state of incident to In progress and comments given by user is should add in activity stream.

Please help me on this.

Thanks and Regards,

Allu Gopal.

4 REPLIES 4

Kieran Anson
Kilo Patron

Hi Allu,

What have you created thus far? Are you using the OOB standard ticket header widget that leverages an action widget?

Hi Kieran,

Thanks for the reply i am yet to develop the requirement but unable to figure out that how to get the input entered by user and save in activity stream as comment.

In the below client controller code user will give the input right? So, how can i store that in a variable and send it to server script code.

eg code in widget:

Html:

<button ng-click="c.onAgree()" class="btn btn-default">Re-Open</button>

Server script:


        data.reopenMsg = gs.getMessage("Incident reopened");
        incidentGr.setValue('state', 2);

incidentGr.setValue('comments', "Reason to Re-Open : "+I want to store that comments enter by user here)
        incidentGr.update();
    

Client controller:

function(spModal) {
  var c = this;
  c.onAgree = function() {
		spModal.open({
			title: 'Do you want to Re-Open the Ticket ?',
			message: "Please provide the reason below.",
			buttons: [
				{label:'✘ ${Cancel}', cancel: true},
				{label:'✔ ${Re-Open}', primary: true}
			]
		}).then(function() {
			c.agree = 'Re-Open';
		}, function() {
			c.agree = 'Cancel';
		})
	}
}

Thanks and Regards,
Allu Gopal.

You can use the example on the developer website of how to use spModal to gather user input, not the "input" flag being true, and the value being bound to a scoped variable

spModal | ServiceNow Developers

function(spModal) {
  var c = this;
  c.onOpen = function() {
        //ask the user for a string
        spModal.open({
            title: 'Give me a name',
            message: 'What would you like to name it?',
            input: true,
            value: c.name
        }).then(function(name) {
            c.name = name;
           //can then perform server update call here
        })
    }
}

Hi Kieran,

Thanks for the response, So if I used like:

Html:

<button ng-click="c.onOpen" class="btn btn-default">Re-Open</button>

Client controller:

function(spModal) {
  var c = this;
  c.onOpen = function() {
        //ask the user for a string
        spModal.open({
            title: 'Re-Open Incident comments',
            message: 'Please provide comments to re-open the incident',
            buttons: [
                {label:'✘ ${Cancel}', cancel: true},
                {label:'✔ ${Ok}', primary: true}
            ]
            input: true,
            value: c.name
        }).then(function(name) {
            c.agree = 'yes';
            c.name = name;
        }, function() {
            c.agree = 'no';
            $scope.$parent.$parent.$dismiss();
        })
      return false;
     $scope.server.update();
    }
}

Server script:     

if(c.name != " ")
{
data.reopenMsg = gs.getMessage("Incident reopened");
 incidentGr.setValue('state', 2);
incidentGr.setValue('comments', "Reason to Re-Open : "+c.name)
incidentGr.update();
}

 

Will this work with that code to store the user input in comments for incident?

Thanks and Regards,

Allu Gopal.