HR Task

kali
Tera Contributor

Hi All,

I am trying to create a task in hr case when hr case is closed complete . Is it possible to create a hr task automatically to the hr case after the hr case is inactive and it is possible to create a hr task automatically when particular hr service and subcategory is selected .

1 REPLY 1

Sandeep Rajput
Tera Patron
Tera Patron

@kali Here are my take on both of your questions.1

 

1. Scenario1:  Is it possible to create a hr task automatically to the hr case after the hr case is inactive

Answer: Yes, this can be achieved via the following business rule on sn_hr_core_case table.

 

Screenshot 2023-10-10 at 5.11.31 PM.pngScreenshot 2023-10-10 at 5.14.01 PM.png

Here is the script.

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var glideHRTask = new GlideRecord('sn_hr_core_task');
	glideHRTask.initialize();
	glideHRTask.setValue('parent',current.getValue('sys_id'));
	glideHRTask.setValue('short_description','<short description for your hr task>');
	glideHRTask.insert();

})(current, previous);

 

2. Scenario2: 

It is possible to create a hr task automatically when particular hr service and subcategory is selected .

Answer: Yes, it is possible, create the business rule as follows.

 

Screenshot 2023-10-10 at 5.16.29 PM.pngScreenshot 2023-10-10 at 5.14.01 PM.png

Here is the script.
(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var glideHRTask = new GlideRecord('sn_hr_core_task');
	glideHRTask.initialize();
	glideHRTask.setValue('parent',current.getValue('sys_id'));
	glideHRTask.setValue('short_description','<short description for your hr task>');
	glideHRTask.insert();

})(current, previous);

Hope this helps.