cancel
Showing results for 
Search instead for 
Did you mean: 

Business rule sends an email when it identifies a "HIGH" in Sevice Call

0 Kudos
368

Hi every one ,

I need your help.

Can you tell me an example of how I can create a business rule that sends an email when it identifies a "high" priority service call only when it meets the following conditions.

1.if the service call is "HIGH" priority and 3 hours have passed since its creation and it has not been closed,

You must send a first email "example1@email.com".

2.if the service call is "HIGH" priority and 4 hours have passed since its creation and it has not been closed,

You must send a first email "example2@email.com"

3. if the service call is "HIGH" priority and 6 hours have passed since its creation and it has not been closed,

You must send a first email "example3@email.com"

Can you help me ?

Accepted Solutions (0)

Answers (4)

Answers (4)

Yanik_Kurzawski
Participant
0 Kudos

Hi Ruben,

to get your current Date and also an substraction on it you can use: DATEADD(NOW() ,' -3 hours')

For your example:

SELECT sc.problemTypeName,

FROM ServiceCall sc

WHERE sc.createDateTime < DATEADD(NOW() ,' -3 hours')

To see which functions do work with query api: https://help.sap.com/docs/SAP_FIELD_SERVICE_MANAGEMENT/fsm_query_api/regular-functions.html?locale=e...

0 Kudos

Hi rubesala1983 ,

As mentioned, I have used pseudo code just to present an idea. It's not ready for copy-paste.

For SQL syntax please check https://www.postgresql.org/docs/current/functions-datetime.html

function now() and operator interval. I assume something like now() - interval '3 hours' should work.

Best regards, Marcin

0 Kudos

Hi Ruben,

This is just some idea, which you could try out. As Christian mentioned above, you need to consider performance of such rule, because the serviceCall table can be huge. The best way is to execute the rule without any action and check, how fast it is. If the execution is under 1 second, then the used select should be fine. So let's select as less ServiceCalls as possible.

My idea in pseudo code:

Add a UDF field "escalation level" to the ServiceCall object.
Create 3 scheduled rules, which run regularly:

1st BR:
-> select ServiceCall, where prio = high, and status != closed and createDate < now()-3 hours and udf.escalationLevel = null;
-> Actions: send e-mail to "example1@email.com", update ServiceCall.udf.escalationLevel = 1;

2nd BR:
-> select ServiceCall, where prio = high, and status != closed and createDate < now()-4 hours and udf.escalationLevel = 1;
-> Actions: send e-mail to "example2@email.com", update ServiceCall.udf.escalationLevel = 2;

3rd BR:
-> select ServiceCall, where prio = high, and status != closed and createDate < now()-5 hours and udf.escalationLevel = 2;
-> Actions: send e-mail to "example3@email.com", update ServiceCall.udf.escalationLevel = 3;

0 Kudos

marcin.tamberg thanks

One questions when you say query :

select ServiceCall, where prio = high, and status != closed and createDate < now()-3

how you do you put 3 hoour because when i put the query it show me "error sintaxis" forma example :

SELECT sc.problemTypeName

FROM ServiceCall sc

WHERE sc.createDateTime > NOW() - 3 hour

CA-113: Query syntax error at position [36] for [SELECT sc.problemTypeName FROM ServiceCall sc WHERE sc.createDateTime > NOW() - 3 hour ]. See: [hour]

christian_hauck
Advisor
Advisor
0 Kudos

Hi Ruben,
there is no possiblity to have business rules triggered on a certain event but with a few hours delay.
Therefore I think the only idea is to have a scheduled rule which selects all open serviceCalls which are older than x hours and sends an email.

But you only should define such a business rule if it is an exceptional situation to have such serviceCalls - to prevent putting to much load in the system.