hrtest

nikhitha24
Tera Guru
 
7 REPLIES 7

Sandeep Rajput
Tera Patron
Tera Patron

@nikhitha24 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.

 

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 = "6816f79cc0a8016401c5a33be04be441"; // Replace with the sys_id of the user
        hrCase.hr_profile = "eb106f19c0a8016401c5a33be04be444"; // Replace with the user's HR profile sys_id
        hrCase.hr_service = "92c63f19c0a8016401c5a33be04be552"; // Replace with the sys_id of the HR service

        // 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.");
        }

Hope this helps.

t

@nikhitha24 You can put a condition inside the business rule script and check the HR Service and accordingly set enquiry type.

t