Create Event to trigger workflow - not working

Ed1
Kilo Contributor

Hello,

i am testing on a dev environment.

I have added in Map Transform a onComplete script to send an Event:

i tested these 2 methods:

var e = new GlideEvent("my_import_servers_1", "", "", "");
e.insert();

and tested also:

gs.eventQueue('my_import_servers_1', "", "", "");

 

In SystemLogs/Events i well see my Event after the transform so it seems to work.

 

In The Flow designer i have added a trigger on this type of Event:

find_real_file.png

But this is never triggered. But if i enter the event and update it of click on reprocess Event, the flow is well triggered.

 

Am i missing something when i create the Event in javascript in onComplete?

 

Thank you for your help

 

1 ACCEPTED SOLUTION

Oh ok,

You can take a look at following link:

 

Script with flows

So, instead add an event to trigger the flow, you can execute the flow with script using the flow API

Hope it helps,

Thanks

View solution in original post

11 REPLIES 11

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

This wont work i think, even if this works you will have issues. Because when the flow triggers it also creates a event in that event table and then this will create a loop.

So just make sure you use this carefully.


Thanks,
Ashutosh

Ed1
Kilo Contributor

Hello,

Thank you for your reply.

When i trigger it by processing again the Event, it's well processed once so no loop issue for me. I filter on the name of the event also as on the screenshot.

Would you have a better idea to trigger the flow automatically after a transform is done a let's say 200 rows were inserted in a table?

 

I thought creating a custom Event in a script with onComplete that would be catched by the trigger of the flow would have been the best approach but maybe you have better to propose (i am new to servicenow, just learning)?

 

Thanks

 

HI,

How are you transforming the data. Using import set?

What you want to achieve?

Thanks,
Ashutosh

Hello Ashutosh,

I load data from an excel sheet. Then i created a table transform Map. With Mapping assist to match field from the temporary table and the final table. Then i click transform to import all the data in the final table. At the end of the transform the 'onComplete' send the Event. And the Flow should be triggered by this Event.

 

The goal is to have the data from the excel sheet in the final table and when done some conditions on the table should be checked (here for test i just do a count of the row where a field has a particular value). I use the flow to check conditions and send mail with result of the flow.

 

All is working fine except this Flow not triggered with the even inserted with:

gs.eventQueue("my_import_servers_1", current, import_set.sys_id, map.sys_id);

but working if i click on reprocess event.

 

Do you have a better idea?

 

Thanks

Hi,

We have transform script to do that validation. You can use onAfter and on Complete scripts to do that and send notification using gs.eventQueue.


Thanks,
Ashutosh