- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 08:33 PM
I have a Screen
When I changed the ‘Week Starts On' of value is not this Week of Manday date ,Then system generate an error message!
How to write a Business Rule?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 09:59 PM
Try with below script :
(function executeRule(current, previous /*null when async*/ ) {
var weekStartOn = new GlideDateTime(current.u_week_starts_on); // Please replace u_week_starts_on with your column Name
var day = weekStartOn.getDayOfWeekLocalTime();
if (day != '1') {
gs.addErrorMessage('Today is not Monday'); // Change the message as per your requirement
}
})(current, previous);
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 08:45 PM
Hi @shiz
You can refer below posts to build this logic -
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 08:50 PM
@Amit Verma hello
I'm not very familiar with the syntax of this writing. How should I write it specifically? Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 09:59 PM
Try with below script :
(function executeRule(current, previous /*null when async*/ ) {
var weekStartOn = new GlideDateTime(current.u_week_starts_on); // Please replace u_week_starts_on with your column Name
var day = weekStartOn.getDayOfWeekLocalTime();
if (day != '1') {
gs.addErrorMessage('Today is not Monday'); // Change the message as per your requirement
}
})(current, previous);
Please mark this response as correct and helpful if it assisted you with your question.