- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 02:14 AM
Hi Team,
I need to append employee Hire date to Journey table title field. I need to do this for 1500 plus users.
That is like: Digital Onboarding - NETHERLANDS CornMine AMP Last name - 2024-02-14
I wrote fix script to pass the employee ids from journey table
Please help to correct
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 03:00 AM
@preethigovi please find the updated one and it should update each journey record with hire date:
var journeyGR = new GlideRecord('sn_jny_journey');
journeyGR.addEncodedQuery('numberINJNY00000949,JNY00000369,JNY00000365');
journeyGR.query();
var jnyMem = []; // Store employee IDs for which we need hire dates
while (journeyGR.next()) {
jnyMem.push(journeyGR.getValue('employee'));
}
// Retrieve hire dates for all employees in one call (assuming getHrDate can handle arrays)
var hr_include = new sn_hr_core.getHiredate().getHrDate(jnyMem);
gs.info('Hire dates retrieved: ' + JSON.stringify(hr_include));
// Update each Journey record
var empMmber = new GlideRecord('sn_jny_journey');
empMmber.addEncodedQuery('numberINJNY00000949,JNY00000369,JNY00000365');
empMmber.query();
while (empMmber.next()) {
var emp_id = empMmber.getValue('employee');
var hireDate = hr_include[emp_id]; // Get the hire date for the employee
if (hireDate) {
// Build the new title
var newTitle = empMmber.title + ' - ' + hireDate;
empMmber.title = newTitle;
// Update the record
empMmber.update();
gs.info('Updated title for ' + emp_id + ': ' + newTitle);
} else {
gs.info('Hire date not found for employee ID ' + emp_id);
}
}
Hope this helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 03:29 AM
Thank You @Abhay Kumar1 It worked. Thanks much
I have to run this fix script for data correction in prod so i don't want to sent any notification to journey employees.
does set workflow(false) helps to restrict?
How i can take that preventive action.