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

This was helpful @OlaN not sure what I missed here 

 

The script below works well but for some reason it clears the RITM due date field, what did I miss? Help

 

var date = fd_data.trigger_get_catalog_variables.termination_date.getValue();

var gdt;

if (!date) {
gdt = new GlideDateTime();

} else
gdt = new GlideDateTime(date + " 00:00:00");
}

gdt.addSeconds(54000);

return gdt.getValue();

 

Regards 

CarolMa

Hello Carol,
Understand the error that should give you reference how to solve your problem. 
It  say cannot convert null to object. So it could not get the field termination_date at runtime.

 

Your script:

// Set Due date to the selected Termination date.

 

var date = fd_data.trigger.request_item.variables.termination_date.getDisplayValue(); 
var gdt  = new GlideDateTime(date + " 00:00:00"); 3
gdt.addSeconds (54000);
return gdt;

 

Thus, this returns empty object it clears  the due date too.

 

Chances are your flow wasnt saved properly, or the flow is corrupted. Thus, you need clear the logs, reload and save again to test the same.

 

Chances also are fd_data.trigger.request_item.variables.termination_date.getDisplayValue();  doesnt directly support the api getdisplayvalue() . Not sure how much testing has already been done on it.

 

Thus, try to get gs.info(fd_data.trigger.request_item.variables.termination_date)  first and then gs.info (fd_data.trigger.request_item.variables.termination_date.getDisplayValue()) in another line and observe the logs. If both are correct then only it would work.

Hi,

Sorry for the slow response.

I've reviewed your updated code, and it looks fine, so at this point I would add a info log statement in the script to see what the value of "gdt.getValue()" actually contains, and if it's empty or something which would have the due date to be cleared.

Then work your way backwards from there to see why the date is empty.

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 !!

@CarolMa6 Did you try my solution ?