Entitlements in CSM

swapnil15
Tera Contributor

Hello All,

In the entitlement, I have selected unit type as hours. I need to subtract the time worked on the case from the total units and show the remaining time in the remaining units field of the entitlement. Can anyone provide me with a Business Rule to update the remaining time automatically based on the time the agent worked on the case?

 

 

PS:  I checked the product documentation, it says to write a BR for hours unit.

3 REPLIES 3

Anand Kumar P
Giga Patron
Giga Patron

Hi @swapnil15,

Write business rule and change script according to your requirements like To deduct hours worked from the total service hours available in the entitlement when a time card is added (approved) and to handle the recall functionality, you should create a Business Rule on the time_card_daily table. 

var caseTask = current.task;
if (caseTask && caseTask.entitlement) {
var entitlement = new GlideRecord('sn_customerservice_entitlement'); //entitlement table name
if (entitlement.get(caseTask.entitlement)) {
var remainingUnits = entitlement.remaining_units || 0;
var hoursWorked = current.hours; 
entitlement.remaining_units = remainingUnits + hoursWorked;
entitlement.update();
}
}

Thanks,

Anand

 

Hello Anand,

Thanks for your response.

 

Pardon, if I am asking basic questions, as I am new to this module.

1. Can you tell me more about the time_card_daily table. How is this table related to entitlements? I cant see any record on time card daily table.

2. What is recall functionality?

3. What should be the condition on BR to execute? (Presuming a user updates the case or closes the case)

Hi @swapnil15 ,

1)The time_card_daily table in ServiceNow is typically used for tracking daily time card entries. Time cards are used to record hours worked or tasks performed by employees, contractors, or service personnel. These records are typically associated with some form of entitlement or work order, such as cases, incidents, or service requests.

2)Recall functionality, service management systems, typically refers to the ability to withdraw or cancel a previously submitted record.
3)After insert br when record inserted take reference below sreenshort

AnandKumarP_0-1697540257827.png

 

Thanks,

Anand