- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2018 09:32 AM
Hi guys,
I am working with the Service Catalog and I have added a text box for users on the portal to add rejection comments. I want these comments to be mandatory, however, when I try to add the error message for the rejection comments it does not recognize it and the user is able to reject the order without comments. How can I get the error message to pop-up?
Here is my code:
Body HTML template
<textarea ng-model="c.data.comment" style="color: grey; width: 100%; margin-top: .5em;" placeholder="Rejection Comments" class="form-control" rows="5"></textarea>
Client Controller
function ($scope, $window, spUIActionsExecuter, spUtil) {
var c = this;
c.action = function(state) {
if ((c.data.comment == undefined || c.data.comment == '' )&& state == 'rejected')
{
spUtil.addErrorMessage("Rejection comments cannot be empty.");
return false;
}
c.data.op = state;
c.data.state = state;
c.server.update();
};
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2018 11:40 AM
Change your ng-click="c.action('approved')" to ng-click="action('approved')", do same fro reject.
Hope this time it helps !!!
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2018 09:59 AM
try adding timer
spUtil.addErrorMessage("Rejection comments cannot be empty.", 1000);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2018 10:13 AM
Your controller should look like this. Highlighted is the change
function ($scope, $window, spUIActionsExecuter, spUtil) {
var c = this;
$scope.action = function(state) {
if ((c.data.comment == undefined || c.data.comment == '' )&& state == 'rejected') {
spUtil.addErrorMessage("Rejection comments cannot be empty.");
return false;
}
c.data.op = state;
c.data.state = state;
c.server.update();
};
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2018 10:48 AM
I tried this, but it is still not working. I press the 'Reject' button and it cancels the workflow, but it won't make the comments mandatory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2018 10:55 AM
I tried same and it worked for me. Could you please share your html as well.
Could you please add an alert in the if block to see control is passing if block or not?
Thanks