- 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:47 AM
Line 15 in the script you pasted.
if(gr.hasNext()) {
gs.info('Test if this is reached! Remove gs.info before going to production');
createTask();
// or:
// this.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:58 AM
Hi Mark,
I have tried with this approach but still it is not working.
Regards,
Nivedita

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2019 03:01 AM
But it is putting in the system log:
gs.info('Test if this is reached! Remove gs.info before going to production');
Or is this already not there, and the IF 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 03:08 AM
I just tried on my PDI. With:
this.createTask();
Working fine.
Can you share your full code of what you have now? Maybe a typo somewhere?
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 03:17 AM
Hi Mark,
Below is my code :
Regards,
Nivedita