Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Portal widget issue

Rosy14
Kilo Sage

Hi,

In Incident Standard ticket Action widget, when resolved is clicked it will open a Modal and that comment will be added to the worknote. I am getting error.

 

 

HTML:

<ul class="dropdown-menu pull-right" id="actionList">
            <li>
                <a ng-if="data.canResolve" href="javascript&colon;void(0)" ng-click="$event.stopPropagation();resolveIncident()" data-toggle="modal" data-target="#myModal">${Resolve}</a>
            </li>

........
<div id="myModal" class="modal fade">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Please let us know the reason your issue no longer needs investigating:</h4>
      </div>
      <div class="modal-body">

        <textarea id="reason" name="reason" rows="4" cols="50" ng-change="getComments(comments)" ng-model="comments">
        </textarea>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="c.uiAction1('ok')">${OK}</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

Client:
 $scope.resolveIncident = function() {
        $scope.data.action = 'resolveIncident';
			
				//RD			
				var textarea = document.getElementById('reason');
        textarea.value = '';
				//RD
			
        $scope.server.update(init).then(function(response) {
            if (response.isIncidentResolved)
                spAriaUtil.sendLiveMessage(c.resolvedIncidentMsg);
        });
        $scope.$emit('focusOnActions', {
            "isFocusRequired": true
        });
    };

	//RD
		   c.uiAction1 = function(action1) {

        c.data.action1 = action1;
        c.server.update().then(function() {

            //c.data.action = undefined;
            c.data.action1 = undefined;
        })

    }
    $scope.getComments = function(com) {
        c.data.getComments = com;
        c.server.update();

    }

Server:
  var act1 = input.action1;
    if (input.action1 == "ok") {
    	if (input && input.action == 'resolveIncident' && incidentGr.get(incidentSysId)&& input.getComments) {
        incidentGr.incident_state = global.IncidentState.RESOLVED;
				incidentGr.state = global.IncidentState.RESOLVED;
				incidentGr.resolved_by = gs.getUserID();
			
				incidentGr.comments="Resolved by colleague:"+"\n"+input.getComments;
				incidentGr.close_notes="Resolved by colleague:"+"\n"+input.getComments;
				data.isIncidentResolved = incidentGr.update();
  	  }
		}

 

 

Rosy14_0-1711376332744.png

 

1 REPLY 1

SanjivMeher
Mega Patron
Mega Patron

in the server script can you add gs.addInfoMessage(JSON.stringify(input)); to the start to know, if you are getting some value.

 

 


Please mark this response as correct or helpful if it assisted you with your question.