Create task in workflow which is running on a custom table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 04:08 AM
Hi,
I have an custom application that is running on a custom table. This custom table is not extending task table. Now I have a requirement where a task has to be created through workflow. I understand that a task cannot be created through workflow if the table is not extended from task.
I'm not sure if I could create my custom table extending task table because apart from creating task through workflow there is no reason for me to extend task table.
Which is the best practice to follow?
1. My custom table extending task table for the sake of creating task in workflow or
2. Is there any other alternative to create task without extending task table from my custom table.
Thanks.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 04:19 AM
You can use Run script activity in the workflow for doing GlideRecord insert into the custom table like as below example than extending from task table
var gr = new GlideRecord('incident');
gr.initialize();
gr.name = 'New Incident';
gr.description = 'Incident description';
gr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 04:24 AM
Thanks for the response, but sorry I didn't get your point.
Please correct me if I'm wrong.
Should I insert field values to task table based upon my requirement?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 04:34 AM
You have mentioned that you want to create a task through workflow right. If table is not extended from task, you will be able to find create task activity and for this you have to use "Run script" activity and use the script to insert records into your custom table.
var gr = new GlideRecord('incident'); // Here you have to input your custom table
gr.initialize();
gr.name = 'New Incident'; //Map the values based on your requuirement
gr.description = 'Incident description'; //Map the values based on your requuirement
gr.insert();
https://docs.servicenow.com/bundle/london-servicenow-platform/page/administer/workflow-activities/reference/r_RunScriptActivity.html

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 05:52 AM
Hi,
you can write script in Run script as below,and you will create record in any table.
Glide the table in which you want to create record.
as below i create incident task by custom table workflow.
in place of incident_task glide the table where you want to create record.
above code will create 3 task in incident_task.
if you face any issue the ask to me.
Mark correct or helpful if it helps you.
Warm Regards,
Pranay Tiwari
| www.DxSherpa.com | pranay.tiwari@dxsherpa.com |