Need to Clear field on a Validation Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2019 06:27 AM
The following BR message is checking to make sure the actual start date is not before the Planned start date on a change. then is throws a message. Can someone help with how I would clear the work_start field in addition to this message.
I've tried "g_form.clearValue('work_start');" before the Abort but this did not work. I think I'm missing an if statement but I don't know how to write it.
Here is the script:
(function executeRule(current, previous /*null when async*/) {
gs.addErrorMessage(gs.getMessage("{0} must be after {1}", [ current.work_start.getLabel(), current.start_date.getLabel() ]));
current.setAbortAction(true);
})(current, previous);
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2019 06:34 AM
Hi,
Can you try setting it simply current.work_start='';
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2019 06:40 AM
Hello Deep,
You can not use g_form in server side code
Try with below line of code:
current.setValue('work_start','');
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2019 07:54 AM
Jaspal,
This worked exactly how I need it to work, however I'm concerned about what Lukasz stated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2019 07:28 AM
Hi,
The GlideForm (g_form) works only on client-side so you can not use it in Business Rule as those run on server-side. You could use current.work_start='' and then current.update() but is highly not recommended to update current, because you will trigger all business rules once again.
I would suggest creating an OnChange client script to validate dates while still on the form, it is more user-friendly.
E.g. you can use the already existing function validateStartDateBeforeEndDate to compare dates:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var showErrorMsg = function(errorMsg){
g_form.clearValue('work_start');
g_form.showErrorBox("work_start",errorMsg);
};
g_form.hideFieldMsg("work_start", true);
validateStartDateBeforeEndDate("start_date", "work_start", showErrorMsg);
}
The result will be like this when the user will put the Actual Start date before the Planned Start Date.
Hope this helped.
Best regards,
Łukasz