- 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
11-29-2016 12:18 PM
To get an onSubmit() script to stop, simply return false. current is not an available object in client scripts (catalog or otherwise.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2016 09:23 PM
Hi Chuck, I am calling a Script Include from Catalog Client Script. In that Script Include I have called current.setAbortAction() and gs.getMessage() function. Please see the screenshots of my Script include and Catalog Client Script.
This is my Script include:
This is my Catalog Client Script:

- 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 02:20 AM
Hi Chuck,
Client script for onSubmit is working fine for portal also.
Thanks.