How to trigger task based workflow from custom table ?

Community Alums
Not applicable

Hi All,

We have a requirement to create one custom table which will have different fields as like cmdb ci tabl, And in the custom table we have different sections which will filled by different teams..

So once the record created we have create multiple tasks and assign them to the respective teams. So for that I have created on custom table A (consider ).

Since my custome table is not inheriting any task table, I am not able to see "Create task" activity. So for creating task, I have created one more table B (consider )which will inherit task table.

Now when ever record the created in my custom table A , I am trying to trigger the workflow which was defined on task table B. Below is the business rule which I defined on table A which will execute even ever record created on table A.

(function executeRule(current, previous /*null when async*/) {

  // Add your code here

  gs.log("executing", "Swamy_workflow");

  var w = new Workflow();

var context = w.startFlow('ce8098064f0032003accfa218110c70c', current, current.operation(), getVars());

  gs.log(context, "Swamy_workflow");

})(current, previous);

But when I created new record on table A, I could not see that table B's   workflow triggered. Am I missing anything ? Anyone could help me on this.

Thanks in advance.

Swamy

6 REPLIES 6

Sanjeev Kumar1
Kilo Sage

Hi,



You need to create a workflow on Table A.


In this workflow you need to create Task on Table B.


It will work.


Community Alums
Not applicable

Hi Sanjeev,



Thanks for your response,



I have already created workflow on Table A (Which is custom table and it is not inheriting any other tables ), But in core activities i can not see Task activity category.



Please check   the below screen shot of workflow.



find_real_file.png



Thanks,


Swamy


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello,



Workflow will be triggered when a record is created. In this use case you need to GlideRecord the target table and then pass the GlideRecord object in the script(instead of current).


I'm not sure what is the exact use. it is better to use the condition field in the workflow properties to start at the appropriate time. Easier to maintain because you don't have the workflow in one place and the trigger in another place.


Community Alums
Not applicable

Dear Pradeep,



Thanks for your response,



Our requirement is we need to create one custom table, which will contain application information, we are planning to create more than 200 fields on the form. and different teams will provide the fields information. That means we have dependency with 5-6 teams (consider W, X, Y Z...) who will provide the information.



For that we have created one costume table A, on this table we are going to add the fields. And when ever a new record created on table A, as per our requirement teams W, X, Y, Z.. have to provide the information ( They want SLA to provide the information also). Our clients wants to create tasks for this dependency. For that we have created a table B which inherits the task table.



So when ever the record created on table A, Based on the application type task will create. For creating task on Table B, I am trying to trigger workflow which will create multiple task based on the provided information. And also we are planning to create SLA on task type table B.



So could you please tell me what exactly I have pass in below script in ( Business rule which will execute from table A) to trigger   table B's workflow.




  gs.log("executing", "Swamy_workflow");


  var w = new Workflow();


var context = w.startFlow('ce8098064f0032003accfa218110c70c', current, current.operation(), getVars());


  gs.log(context, "Swamy_workflow");



Below is the workflow   which I defined on table B and   want to trigger when record created on table A.



find_real_file.png



Thanks,


Swamy