Ticket is not getting created through Scheduled job

mania
Tera Contributor

Hi,

 

I have created an automatic ticket for every first day of the week and auto-assign to a particular user through scheduled job but that ticket is not getting created.

The below is the code so can anyone please help on this, It will be usefull.

mania_0-1722523039379.png

Thanks!

6 REPLIES 6

Hemanth M1
Giga Sage
Giga Sage

Hi @mania ,

 

Few things here

1)Did u try this code in the background script , you will be able to identify the issue.

2)Did u try executing using execute now button here

3)Use finction to call this block of code

something like :

 

createInc();

function createInc(){
//incident creation logic
}

 

 

4)pls replace hardcoded values with system property and use setValue instead direct assignmnet

OR

I would write a scheduled flow instead scheduled job.

 

Hope this helps!!

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Aditya Banka2
Tera Guru

It seems the issue with line 2.

 

AdityaBanka2_0-1722531608757.png

It seems in your case the GlideRecord didn't initialized properly. If it's initialized properly, then it should appear in Italic.

Try removing it and re-write it again.

 

Mark it as Helpful and mark it as Solved, if this resolves your issue.

abirakundu23
Mega Sage

Hi @mania,

I have written below code which is creating an incident using schedule job.

abirakundu23_0-1722533711472.png

does your code create a ticket once you click on execute now? or create ticket but not automatically?
Please mark helpful & correct answer if it's really worthy for you.

@abirakundu23 

Thanks for your Responded!

Yes, once I clicked on execute now button it is created a ticket and not created automatically. I want automatically create the record.

Please help on this, it will be usefull.

Thanks!