Skip to main content

Scheduled execution of a custom script


dsj
Superhero (Partner)
Forum|alt.badge.img+22
  • Superhero (Partner)
  • 843 replies

There were several posts regarding the requirement of schedule execution of a custom script in IFS. There could be several ways of doing this and this topic explains how to build a common solution using Events and Scheduled Tasks.

IFS has two event types, Application Defined and Custom defined. Custom defined events are based on triggers and can be created from IFS Solution Manager. Application defined events are created via script and the triggering of the event is done inside the PLSQL logic. 

 

Step1: Create Application Defined Event and action

Deploy following code in database using AppOwner. Check the attachment for detailed script.

BEGIN
   Event_SYS.Enable_Event('Event', 'C_SEND_DOC_REV',
                          'Send Document revision',
   'DUMMY/STRING^');
END;

 

Navigate to the Events and search for the event ID.

 

RMB on the event,  Create new action

Choose the Action Type SQL and write your code to execute on a schedule.

 

 

Step 2: Create the Scheduled Task

Navigate to New Database Task window and create a new database task for Event_Sys.Event_Execute method, Save

 

Create a new Scheduled task. Fill the event LU and event ID which is we created in step 1. Schedule it as per your requirement.

 

That's basically all you need to schedule your custom script!

 

👍 this topic if you think it’s useful and comment any other ‘hacks’ or suggestions.

 

Cheers!

This topic has been closed for comments

15 replies

GPIE
Hero (Customer)
Forum|alt.badge.img+11
  • Hero (Customer)
  • 113 replies
  • November 23, 2020

If only I’d know this a year ago! :sob:

Thanks @dsj.


Forum|alt.badge.img+6
  • Sidekick
  • 10 replies
  • November 24, 2020

 Hi @dsj 

Thank you! But it didnt get one thing. Is this work for all doc revision ? I mean how can  I sent the document that I want to send via e mail for using your solution? Where should I select it?


dsj
Superhero (Partner)
Forum|alt.badge.img+22
  • Author
  • Superhero (Partner)
  • 843 replies
  • November 24, 2020
Amy wrote:

 Hi @dsj 

Thank you! But it didnt get one thing. Is this work for all doc revision ? I mean how can  I sent the document that I want to send via e mail for using your solution? Where should I select it?

Hi Amy,

This post explains more of a general way of executing some action on a scheduled. You can write the pl/sql code in the event action to select the document(s) and send via mail :)

 

Regards,

Damith

 

 

 


0guz
Hero (Employee)
Forum|alt.badge.img+10
  • Hero (Employee)
  • 64 replies
  • November 25, 2020

@dsj It is amazing trick i think! Thank you so much.

@Amy i want to see your pl SQL block for sent to mail with documents with script, Can you share with me?


Forum|alt.badge.img+6
  • Sidekick
  • 10 replies
  • November 25, 2020

Hi @oguz

 

I’d like to send it but I havent have it yet  :( I’ll work on it 


dsj
Superhero (Partner)
Forum|alt.badge.img+22
  • Author
  • Superhero (Partner)
  • 843 replies
  • November 25, 2020
Amy wrote:

Hi @oguz

 

I’d like to send it but I havent have it yet  :( I’ll work on it 

 

Hi @Amy and @0guz ,

 

I’ve had the similar requirement to mail several document revisions in a mail and luckily for you, I have a blog post explaining the steps :sunglasses:

You could use the same steps in the below blog with modifications to the cursor to fetch the document

https://dsj23.me/2017/03/20/include-additional-attachments-in-ifs-e-mail-report/

 

Hope you could make it work.

Cheers!

Damith


Forum|alt.badge.img+6
  • Sidekick
  • 10 replies
  • November 27, 2020
dsj wrote:
Amy wrote:

Hi @oguz

 

I’d like to send it but I havent have it yet  :( I’ll work on it 

 

Hi @Amy and @0guz ,

 

I’ve had the similar requirement to mail several document revisions in a mail and luckily for you, I have a blog post explaining the steps :sunglasses:

You could use the same steps in the below blog with modifications to the cursor to fetch the document

https://dsj23.me/2017/03/20/include-additional-attachments-in-ifs-e-mail-report/

 

Hope you could make it work.

Cheers!

Damith

 

 

Thank you very much!


Forum|alt.badge.img+4
  • Do Gooder (Customer)
  • 5 replies
  • April 1, 2021

My only problem is that when I set up the Scheduled Task,  I can’t find the EVENT_SYS.EVENT_EXECUTE when I browse the methods. I’m talking about Apps9. Where is it?? Help! Thanks!


Forum|alt.badge.img+4
  • Do Gooder (Customer)
  • 5 replies
  • April 1, 2021

Solved my own problem! 

In case anyone else has issues, when you click “Select Method”, it’s here:

IFS Base Functionality > Event > EVENT_SYS


krestensb
Sidekick (Customer)
Forum|alt.badge.img+8
  • Sidekick (Customer)
  • 40 replies
  • April 12, 2021

Could you please explain how I could access the EVENT_DATA_ in my pl/sql event action ?

That would be very helpful.

BR Kresten


dsj
Superhero (Partner)
Forum|alt.badge.img+22
  • Author
  • Superhero (Partner)
  • 843 replies
  • April 12, 2021
krestensb wrote:

Could you please explain how I could access the EVENT_DATA_ in my pl/sql event action ?

That would be very helpful.

BR Kresten

 

Hi Kresten,

 

EVENT_DATA_ is a IFS Message which constructed using Message_Sys. When executing events, it packs the values for event attributes and call the event. But in this case we can’t add the event_data_ since it has a special format and  sparerate with new lines so it’s not possible to add it in the Task Schedule window.

Hope it helps!

Damith


krestensb
Sidekick (Customer)
Forum|alt.badge.img+8
  • Sidekick (Customer)
  • 40 replies
  • April 13, 2021

OK, but could you somehow create the event in a way where that is possible?


dsj
Superhero (Partner)
Forum|alt.badge.img+22
  • Author
  • Superhero (Partner)
  • 843 replies
  • April 13, 2021
krestensb wrote:

OK, but could you somehow create the event in a way where that is possible?

 

You just need to create the event with the parameters needed.

Below event is created with two attributes (contract and wo_no)

BEGIN
   Event_SYS.Enable_Event('Event', 'TEST_EVENT',
                          'Test Event',
   'CONTRACT/STRING^WO_NO/NUMBER^');
END;

 

They will appear in the event action and you can use them as usual.

 

How to assign values to the event attributes and execute the event

You need to create a IFS message, pack the attribute values and call the event.

DECLARE
  event_enabled_ BOOLEAN := Event_SYS.Event_Enabled('Event','TEST_EVENT');
  event_msg_     VARCHAR2(32000);

BEGIN
  IF event_enabled_ THEN

    event_msg_ := Message_SYS.Construct('TEST_EVENT');
    Message_SYS.Add_Attribute(event_msg_,'CONTRACT','01'); --contract
    Message_SYS.Add_Attribute(event_msg_,'WO_NO','77568'); --wo no

    event_sys.event_execute(event_lu_name_ => 'Event',
                          event_id_ => 'TEST_EVENT',
                          event_data_ => event_msg_);

  END IF;
END;

 

Hope it helps!

Damith

 


Forum|alt.badge.img+1
  • Do Gooder (Customer)
  • 1 reply
  • October 5, 2021

An other option is using EVENT_DATA_ (with a little trick)

You can use LF (character number 10 in the ASCII charset) - You will need a special editor to do that Notepad++ , UltraEdit, …

Ex:

$NEW:CATALOG_NO=123456

$NEW:CONTRACT=Test

You need a LF after each of the parameters like this:

$NEW:CATALOG_NO=123456<LF>$NEW:CONTRACT=Test<LF>


Forum|alt.badge.img+8

Hello,

EVENT_SYS.EVENT_EXECUTE method is no longer accessible in "New Database Task Schedule" form in 21R1 and R2, even with IFSAPP. It was very useful to schedule an event action without triggering the action itself. Today, combined with the bpa, it could make all the difference.

Does anyone know of a way to retrieve it or an alternative ?


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings