- 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 02:49 AM
Hi,
From this output, it is clear that some of the object is not converted into string.
Make change to this line where empMmber.title is set:
empMmber.title += ' ' + '-' + JSON.stringify(a);
Also ensure that below line is correct:
var a= jnyMem[i]=hr_include[i];
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 02:59 AM
Hi @palanikumar .
Even then issue happens. I want to map the hire date that i got from script include to respective employees
this is what i got from script include

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 03:06 AM
Can you update the below line and let me know the output
var a= jnyMem[i] + " - " + hr_include[i];
Palani
- 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.