Flow designer workflow error: cannot convert null to an object

CarolMa6
Tera Expert

Hi, 

 

what am I missing in this flow? The workflow is not triggering the related SCTASK because of the "cannot convert null to an object" error 

 

see below - 

CarolMa6_0-1754999807910.png

CarolMa6_1-1754999829626.png

Regards 

CarolMa

 

 

1 ACCEPTED SOLUTION

SANDEEP28
Mega Sage

@CarolMa6 Use below scripts. Don't use getDisplayValue() for date type of field. It is giving undefined value . I tried below script in PDI and it worked.

 

var date = fd_data._1__get_catalog_variables.termination_date;
var gdt = new GlideDateTime(date + " 00:00:00");
gdt.addSeconds(54000);
return gdt;

  

  If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

View solution in original post

11 REPLIES 11

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @CarolMa6 

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0855574

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

@Dr Atul G- LNG 

 

See screenshot below issue not related the "Run As" field set to System User

 

CarolMa6_1-1755000538492.png

Regards 

CarolMa

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@CarolMa6 

the error clearly is because of that script.

Is that variable as standalone and not part of MRVS?

If yes then Did you check if variable name is correct?

that variable is of type Date or Date/Time?

Did you add logs and see what came in date variable?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

OlaN
Giga Sage
Giga Sage

Hi,

Probably you need to make sure that the "date" variable in the first line contains some data, before you try to add/convert the date to a datetime.

 

Something like below might help (somewhat simplified example).

var date = fd_data.trigger......getDisplayValue();
var gdt;

if (!date){
  // some action to take if the value does not exist
  gdt = new GlideDateTime();
  ....
}
else{
  gdt = new GlideDateTime(date + ...);
  gdt.addSeconds(...);
}

return gdt.getValue();