Getting Undefined Value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 04:14 AM - edited 04-12-2024 04:23 AM
Hi All/ @Murthy Ch ,
Created schedule job that set case assignment to automatically. But adding add() or addDays() logic we get 'undefined' value through log. Could you please help me ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 11:32 PM
undefined. I am not sure but why it is showing 'undefined' when used with functions like addDays(), addMonths() etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 07:55 AM - edited 04-15-2024 07:56 AM
Hi @Sagar Pagar ,
I am still getting the same error message - "Add days: undefined".
var date1 = new GlideDateTime(caseupdate.opened_at.toString()); var days= date1.addDaysLocalTime(2); gs.info ("Add days:" + days);
Please suggest me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 09:14 AM
Hi @abirakundu23 ,
I tried your problem in my PDI and It works for me, please refer below code
var caseupdate = new GlideRecord("sn_hr_le_case");
caseupdate.addEncodedQuery('active=true');
caseupdate.query();
while(caseupdate.next())
{
var date = new GlideDateTime();
var date1 = new GlideDateTime(caseupdate.opened_at);
gs.print("Created date:" +date1);
date1.addDays(2);
gs.print("Add days:" + date1.getDate());
if(date == days && caseupdate.u_country == 'IN')
{
caseupdate.assignment_group = '' ;//sys_id of the group
gs.print("Case assignment successfully");
}
}
gs.print("Case assignment successfully12");
Here you are using days varible for prinit which show undefined, you need to print that same variable which you are doing GlideDateTime i.e. date1 and you need to call the method date1.getDate()
Result:
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 08:59 PM - edited 04-15-2024 09:00 PM
Hi @Community Alums ,
Thanks for your update. Now we are getting log after adding addDays().
But these lines of code does not execute.
After if condition log is not executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 09:22 PM
Hi @abirakundu23 ,
Reasone behind your code didn't execute if condition is yours days is 2 days extra in opened_at date. It will work after 2 days when date and days value are same.
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak