- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017 12:17 AM
Hi,
In change module form approvers list, if I reject the approval from list view then it should check for the comments field and if it is null, an error message should be thrown in the change form and should abort the action until I fill the comments in the list view.
I tried writing an business rule but it is not working
Condition : State changesto "rejected"
Script:
(function executeRule(current, previous /*null when async*/) {
if(current.comments == ''){
gs.addErrorMessage('Please enter comments on rejection');
current.setAbortAction(true);
}
})(current, previous);
It is throwing an error message but when I fill the comments field and try to submit the same error message is throwing. Could anyone help me to solve this issue?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017 12:26 AM
Hi Asha,
The issue is that you are doing this from the list view which will update each field as you leave the field. And since comment is a journal field you cannot do it this way.
You can try to use "current.comments.getJournalEntry(-1)" instead of "current.comments" in your if statement.
This will output all comments as a string. If that string is then empty there is no comments.
I hope this helps
/Lasse
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017 12:26 AM
Hi Asha,
The issue is that you are doing this from the list view which will update each field as you leave the field. And since comment is a journal field you cannot do it this way.
You can try to use "current.comments.getJournalEntry(-1)" instead of "current.comments" in your if statement.
This will output all comments as a string. If that string is then empty there is no comments.
I hope this helps
/Lasse
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017 11:25 PM
Hi Lasse,
Thank you so much, it worked perfectly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017 11:30 PM
You are welcome 🙂
Please remember to mark my answer as correct, so that other people can see that your question has been answered and so that it is easier for them to find the solution.
Have a nice day!
/Lasse