- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2012 10:00 AM
Hi everyone, wanted to ask a question about something that recently happened. before the creation of a record, I have a few before business rules that run to make sure the information supplied is correct. For example, a date field. If the user entered date does not fall on a sunday, submission of the record is cancelled and they are prompted to change that date. It works fine, but only if one mistake is made. Example....I user tries to submit with incorrect information, an error is thrown and they are prompted to change the value. Now lets say they enter another incorrect value, the error is thrown again. They then change to a correct value and submit the record. A "Record not found" error is appearing, but if I look at the list, it was inserted. Can anyone explain why this is happening? Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2012 06:54 AM
try something like this:
function onSubmit()
{
var ajax = new GlideAjax('TimeCardDateAjax');
ajax.addParam('sysparm_name','TimeCardDate');
ajax.addParam('sysparm_week_starts_on', g_form.getValue('week_starts_on'));
ajax.getXMLWait();
var val = ajax.getAnswer();
g_form.addInfoMessage(val); //testing to see what parameter is coming from script include
if(val == '1')
{
return true;
}
else
{
g_form.addErrorMessage("Some Error in here")
return false;
}
}
Then in the Script Include:
var valid = 0;
var weekStarts = this.getParameter('sysparm_week_starts_on');
var weekStartsObj = new GlideDateTime(weekStarts); //may need to look up correct syntax in the wiki for new GlideDateTime
if(weekStartsObj.getGlideObject().getDayOfWeekUTC() == '7')
{
valid = 1;
]
return valid;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2012 08:33 AM
I got it....had to change the if statement to the following
if(weekStartsObj.getDayOfWeekUTC() == '7'
Im thinking I didnt need to use the method getGlideObject() becuase weekStartsObj was declared as such. Thanks for the guidance Chris. I appreciate your time.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2012 09:08 AM
Not a problem. Would you mind marking the thread as "Answered"?