- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2019 05:25 AM
Hi,
My requirement is when any user profile is inactive in users table then it should create one task.
Can anyone help me to create task through business rule or script include?
Thanks In Advance!
Nivedita
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 04:27 AM
Hi there,
What exactly do you mean task function seems not to be right, do you get an error? Have you directly checked the sc_task table to check if the record is created?
If I execute below code in background script it immediately works. So the GlideRecord query should be oke.
checkApp();
function checkApp() {
createTask();
}
function createTask() {
var task = new GlideRecord('sc_task');
task.initialize();
task.short_description = 'something';
task.insert();
}
Please mark my answers as helpful, as they are helping you find a way to a nice solution.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 02:17 AM
Hi,
I have created one business rule and one script include to create a task with condition user is inactive and user has assigned "xxx" application but it is not creating any task.
Below is my script include :
Can anyone please suggest me am i doing anything wrong for task creation function?
Regards,
Nivedita

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 02:30 AM
Hi there,
How far did you go with the debugging? I see some gs.log statements, did they work?
For example, line 7, is this printed in the logs? Is the checkApp reached.
Put an extra gs.log / gs.info on the if, on line 15. Is this reached or is the IF already failing?
Line 23, did this got printed in the logs? If not, the createTask is not reached.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 02:36 AM
Hi Mark,
I see in the logs line 7 and line 15 is printed in the logs but line 23 is not printing in logs.
Could you please correct me where i am doing wrong in task function?
Regards,
Nivedita

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 02:40 AM
Ah good debugging.
Then it might be the way how you call createTask function (line 15 in your example).
Can you change that to:
this.createTask();
Or just - i'm not sure 🙂 -:
createTask();
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 02:44 AM
Hi Mark,
I didn't get that where i need to do changes?
Regards,
Nivedita