Expand my Community achievements bar.

SOLVED

how to set alert and test activity to compare when file found and no file found

Avatar

Level 5

 

 

i want to run a import workflow that is scheduled to run in every 30mins

now if no file is received in last 5hours i want to send an alert
please help me how can i achive this

 

 

 

 

@ParthaSarathy

@ParthaSarathy 

@ParthaS 

@AkshayAnand 

@Craig_Thonis 

@Manoj_Kumar_ 

@Amine_Abedour 

@Marcel_Szimonisz

@DavidKangni 

@Amit_Kumar 

@ShashankNigam02

@Ganesh5067

@Jonathon_wodnicki

 

i know this can be achived like 

a File Transfer activity and enable the 'Process missing file'. In the file found transition, store the datetime in which the file was received in an option or variable. When there is no file, compare the current datetime with the time stored in the option or variable and send an alert.

but m unable to set option varibale like how to get bith dates and comapre in test acticity

please help me with the code for test and js activity: date comparison

 

please help m stuck here

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Shruti1 ,

You can also try below approach,

ParthaSarathy_0-1706861251198.png

Connect a JavaScript Code activity in 'Ok' transition of file transfer, and enter the below script inside JS code activity

logInfo("File Processed")

 

'No file' Transition:

Query:

Targeting & Filtering Dimension: xtk:workflow

Filtering Condition:

@internalName equal to internal_name_of_current_workflow

AND

Message (log)   do not exist such as

        @message    equal to    File Processed

         AND

        @logDate      equal to    SubHours(GetDate() , 5)    

ParthaSarathy_1-1706861745954.png

 

Test Activity:

vars.recCount > 0

ParthaSarathy_2-1706861809039.png

 

And configure the Alert activity.

Now when there is file present, 'File Processed' log will get generated. If there is no file processed in last 5 hours, an Alert will get triggered.

 

 

View solution in original post

4 Replies

Avatar

Level 3

Hi @Shruti1 ,

If you are importing from SFTP, add an "Archive" folder there, and start moving files to archived when processed. Now you will have only the latest file in your incoming folder. While Importing file in AC, you can now add a test activity and Alert to process the alert in case of missing file.

 

Avatar

Community Advisor

Hello @Shruti1 

 

Once the file is ingested successfully set the Option by this code:

setOption('lastingestion',new Date());

 

Then, in the new workflow, use this code to check the difference between the last ingestion and the current time.

var lastingestion=getOption('lastIngestion')

var now=new Date();

instance.vars.hoursDiffer = Math.abs(now - lastingestion) / 36e5;

 

 

Then, use the test activity to check if the difference is 5 hours.

Manoj_Kumar__0-1706482672650.png

 


     Manoj
     Find me on LinkedIn

Avatar

Correct answer by
Community Advisor

Hi @Shruti1 ,

You can also try below approach,

ParthaSarathy_0-1706861251198.png

Connect a JavaScript Code activity in 'Ok' transition of file transfer, and enter the below script inside JS code activity

logInfo("File Processed")

 

'No file' Transition:

Query:

Targeting & Filtering Dimension: xtk:workflow

Filtering Condition:

@internalName equal to internal_name_of_current_workflow

AND

Message (log)   do not exist such as

        @message    equal to    File Processed

         AND

        @logDate      equal to    SubHours(GetDate() , 5)    

ParthaSarathy_1-1706861745954.png

 

Test Activity:

vars.recCount > 0

ParthaSarathy_2-1706861809039.png

 

And configure the Alert activity.

Now when there is file present, 'File Processed' log will get generated. If there is no file processed in last 5 hours, an Alert will get triggered.