Transform Script - Choice Action = reject, creats undefined Reference

Meloper
Kilo Sage

Hay,

i have a Field Script searching for CIs in CMDB.

When this CI does not exist or it has the wrong status. I end the function with a return;

Choice Action is reject!

My problem is that the record is created anyway. The field value is undefined.
I already have it with
return "0";
reurn NULL;
etc. are tried.

I thought that with reject no value is written and no record is created if the reference is not found...

Which return value is needed to make reject work?

 

Target Field Name Installed on Ref: cmdb_ci
Choice Action: reject

1 ACCEPTED SOLUTION

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

you don't need to add anything in return, simply select the Choice Action to reject.

For any further information, please refer to the following official documentation:

https://docs.servicenow.com/bundle/paris-platform-administration/page/script/server-scripting/task/t...

If I have answered your question, please mark my response as correct and/or helpful.

Thank you very much

Cheers
Alberto

View solution in original post

3 REPLIES 3

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

you don't need to add anything in return, simply select the Choice Action to reject.

For any further information, please refer to the following official documentation:

https://docs.servicenow.com/bundle/paris-platform-administration/page/script/server-scripting/task/t...

If I have answered your question, please mark my response as correct and/or helpful.

Thank you very much

Cheers
Alberto

Ankur Bawiskar
Tera Patron
Tera Patron

@Meloper 

if you don't want record in target reference table to be created then you can set choice action as ignore

if you want import set row to be rejected then your field map should look like this

answer = (function transformEntry(source) {

  if(value found){

 return sys_id;

  }

  else{

  return -1;

   }

})(source);

Regards
Ankur

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Meloper 

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

If not, please let us know if you need some more assistance.

Regards
Ankur

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