How can i make mandatory the rating to Knowledge articles while submission feedack

lakng
Tera Contributor

i have knowledge articles in portal, user can open the KB article and they can select the option weather it is useful or not.

and they can submit their feedback.

but here i need to make mandate the giving the rating while giving the feedback.

how can i achieve this

4 REPLIES 4

Akshata jamdar
Mega Guru

Hi lakng,

 

Could you please tell which type of field you are using for rating?

 

Regards,

Akshata

Uncle Rob
Kilo Patron

Imagine every interaction with every company you've ever done business with outside ServiceNow.

Now imagine they forced you to provide a rating on any interaction. 

How would that make you feel?

Your customers don't exist to fill in your blanks.  We're providing THEM the service, not the other way around.  Your customers will hate you for this, and probably radically reduce the amount of feedback they give (if they're giving it at all).

Thank your customer for the time they took from their REAL job to give you feedback, and move on.  Don't make dealing with support even more difficult than it already is.

Akshata jamdar
Mega Guru

Hi,

Rating and feedback is one of the property of knowledge article.

There is no any field or variable associated.

 

Regards,

Akshata

Sri Harsha3
Tera Expert

Hi,

To make the ratings mandatory in feedback, clone the widget "KB Article comments". Modify the below lines in the cloned widget.


Here I have added a span tag and class for rating:

 

<form ng-submit="submitFeedback()" ng-if="!data.disabled && data.isValid && (data.allowFeedback || data.allowRating)" >
    <div class="form-group">
      <label ng-if="::data.allowFeedback" for="comment"><h3 class="h4">${Add your comment}</h3></label>
      <textarea ng-if="::data.allowFeedback" ng-model="data.comments" class="form-control" rows="2" id="comment"></textarea>
      <span ng-if="data.comments!=''">{{data.rating_required}}</span>
      <span ng-class="{'required': data.comments}" ng-if="::data.allowRating">${Rate this article}<uib-rating sp-rating ng-model="data.rating" max="5" aria-label="${Rate this article}" state-on="'fa fa-star kb-star-on'" state-off="'fa fa-star kb-star-off'"></uib-rating></span>
      <input ng-if="::data.allowFeedback" type="submit" id="submit" value="{{data.submitMsg}}" class="btn btn-primary" style="margin-top: 5px;" ng-disabled="!data.comments && !data.rating"/>
    </div>  
  </form>

 


<span ng-if="data.comments!=''">{{data.rating_required}}</span>
<span ng-class="{'required': data.comments}" ng-if="::data.allowRating">${Rate this article}

In CSS add

span.required:after {
content: ' *';
color: #f00;
}

In Client Script add

 

$scope.$watch("data.comments", function() {
        if ($scope.data.comments) {
            $scope.data.rating_required = 'Thank you, Please rate us';
        }
    });
    $scope.submitFeedback = function() {
        if ($scope.data.comments != '' && $scope.data.rating == '') {
			$scope.data.rating_required = 'Thank you, Please tell rate us';
			return false;
        } else {
            $scope.server.update().then(function() {
                if ($scope.data.response)
                    spAriaUtil.sendLiveMessage($scope.data.response);
            });
        }

    }

 

After these you should be getting rating as mandatory.

 

If this solves your problem kindly mark as correct answer and helpful