hrtest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 08:42 AM - edited ‎04-09-2025 09:03 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2024 01:22 AM
You can write an onBefore Update business rule on sn_hr_core_case table with condition HR Service is Travel AND State Changes to Closed Complete. In the business rule script, you can create a new HR case as follows.
Please update the aforementioned script as follows.
var hrCase = new GlideRecord('sn_hr_core_case');
hrCase.initialize();
// Set mandatory and required fields
hrCase.short_description = "Example HR Case Created via Script";
hrCase.description = "This HR case is created via a script for demonstration purposes.";
hrCase.opened_for = current.opened_for+'';
hrCase.subject_person = current.subject_person+'';
hrCase. subject_person_hr_profile = current. subject_person_hr_profile;+''
hrCase.hr_service = "92c63f19c0a8016401c5a33be04be552"; // Replace with the sys_id of the HR service
var hrServiceName = current.hr_service.name; // Assuming 'name' is the HR service name field
if (hrServiceName == 'Travel') {
current.u_enquiry_type = 'New Starters'; // Update enquiry type to New Starters
} else {
current.u_enquiry_type = 'New Hire'; // Update enquiry type to New Hire
}
// Insert the record into the HR case table
var caseSysId = hrCase.insert();
if (caseSysId) {
gs.info("HR Case created successfully with sys_id: " + caseSysId);
} else {
gs.error("Failed to create HR Case.");
}
Please mark the response accepted solution if it addresses your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 01:22 PM
Have you tried using Service Activities? This will be simpler and configuration driven and not require any scripting.
In your initial HR Service definition, set the Fulfillment type to "Service Activity". This should display the Service activities related list.
Create a new service activity of type "Child HR Service", and set your required HR Service.
This is simpler and configuration driven, and does not require any additional scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2024 03:44 AM
Hi @Seema Hegde
Where can we mention the condition such as State is Close Complete of parent HR case?