- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2016 12:14 PM
I have a Joiner Form Catalog Item where new Joinees enter their Start Date and End Date for their Joining. Here 'Start Date' and 'End Date' are variables of 'Joiner form' Item. I was trying to write a Catalog Client Script for type = onSubmit. I tried by passing Start Date and End date values to Script include and compare it. All are working fine but current.setAbortAction() and gs.getMessage() funcions are not working. So even after showing error message by g_form.addErrorMessage() in Client script the record gets created. I want to abort this record submission.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2016 06:11 AM
Here's the client script I used to validate start/end dates on a record producer.
function onSubmit() {
var jsStartDate = new Date(g_form.getValue('work_start'));
var jsEndDate = new Date(g_form.getValue('work_end'));
var jsToday = new Date();
if (jsStartDate < jsToday) {
alert(getMessage('loaner_error_start_before_today'));
return false;
}
if (jsEndDate < jsStartDate) {
alert(getMessage('loaner_error_end_before_start'));
return false;
}
return true;
}
Then I also run a (before insert/update) business rule when fulfillers are updating the record in case two pick the same resource, one submits and it's OK and the second gets a conflict.
(function executeRule(current, previous /*null when async*/) {
var start = new GlideDateTime(current.work_start).getNumericValue();
var end = new GlideDateTime(current.work_end).getNumericValue();
if (start > end) {
var msg = gs.getMessage('loaner_error_end_before_start');
gs.addErrorMessage(msg);
current.work_start.setError(msg);
current.setAbortAction(true);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2016 05:54 AM
So is this working now? If so, please mark my appropriate response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2018 10:30 AM
Please if I need to add the redirection after the alert like [current.u_record_producer = "1c3728a113b1db80e7d973076144b09b"; ] but from a client script ?