- 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 03:23 AM
Hi there,
But again, can you confirm that the if(gr.hasNext on line 15 is reached? There could well be something before already wrong, or the gliderecord query not having result. Please put some gs.info within the if, for example on line 16 and confirm this is working.
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:45 AM
Hi Mar,
You are correct i have put gs.info within the if, after line 16 and but it is not working, gliderecord query not having result.
Could you please help me with condition.My condition is like when user is active, configuration item is VDI WAAS" and then it should create task.
Regards,
Nivedita

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2019 03:54 AM
Hi there,
Go to the u_user_access_application, try to build your query there. Just with the condition builder. Then right click on the end of the breadcrumb, and select "Copy query". This will give you exactly the working query you want. Maybe only you have to replace on variable to make it dynamic. That encoded query, you can exactly use on line 10 of your script.
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 04:15 AM
Hi Mark,
Thanks for all you help.
Now i have put gs.info within the if,on line 16 and can see that this is working now if condition is returning value but it seems in task function something is wrong so task has not been creating.
Regards,
Nivedita
I

- 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