Record Not Found / Business Rules

Mikolz
Kilo Contributor

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.

1 ACCEPTED SOLUTION

cwilker10
Giga Expert

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;


View solution in original post

6 REPLIES 6

Mikolz
Kilo Contributor

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.


Not a problem. Would you mind marking the thread as "Answered"?