Get Hire date from HR profile and add at end of Journey title

preethigovi
Tera Contributor

Hi Team,

I need to get the employee hire date from HR profile and append to end of Journey Title.

HR profile and Journey both are of different scopes.

 

Please help on how to achieve this

preethigovi_0-1730729406472.png

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@preethigovi 

how it's rendered currently?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

Its the data correct i need to do for 2000 plus record in Journey table.

I need to update Digital Onboarding(Demo) - Siyan Hu to Digital Onboarding(Demo) - Siyan Hu-4.11.2024

Means, I need to get the Hire date from HR profile(human resource scope) and then update the title of journey in journey designer scope. Please help

Hi @Ankur Bawiskar ,

 

I have mostly written the code.

Fix Script in Journey table to pass the journey and employee ids

 

var jnyMem = [];
var journeyGR = new GlideRecord('sn_jny_journey');
journeyGR.addEncodedQuery('numberINJNY00000949,JNY00000369,JNY00000365');
journeyGR.query();
while (journeyGR.next()) {
    jnyMem.push(journeyGR.getValue('employee'));
}
gs.info('Preethijny1 ' + JSON.stringify(jnyMem))

var hr_include = new sn_hr_core.getHiredate().getHrDate(jnyMem);
gs.info('Preethijny3 ' + JSON.stringify(hr_include));

var jnyRecord = new GlideRecord('sn_jny_journey');
jnyRecord.addEncodedQuery('numberINJNY00000949,JNY00000369,JNY00000365');
jnyRecord.query();
while (jnyRecord.next()) {
    var emp_id=jnyRecord.getValue('employee');
    for (i = 0; i < hr_include.length; i++)
        jnyRecord.title += ' - ' + hr_include[i];
    gs.info('preethijny4 ' + jnyRecord.title)
    //jnyRecord.update();
}
 
this gets the hire date from from HR profile script include. Until that its works fine.
Now i have to map each hire date to each journey employee title iam failing in that

preethigovi
Tera Contributor
var jnyMem = [];
var mapped_id = [];
var associatedDate;
var journeyGR = new GlideRecord('sn_jny_journey');
journeyGR.addEncodedQuery('numberINJNY00000949,JNY00000369,JNY00000365');
journeyGR.query();
while (journeyGR.next()) {
    jnyMem.push(journeyGR.getValue('employee'));
}
gs.info('Preethijny1 ' + JSON.stringify(jnyMem))

var hr_include = new sn_hr_core.getHiredate().getHrDate(jnyMem);
gs.info('Preethijny4 ' + JSON.stringify(hr_include));
var empMmber = new GlideRecord('sn_jny_journey');
empMmber.addEncodedQuery('numberINJNY00000949,JNY00000369,JNY00000365');
empMmber.query();
while (empMmber.next()) {
    var emp_id = empMmber.getValue('employee.sys_id');
    //associatedHireDate = hr_include[emp_id];
    empMmber.title += ' ' + '-' + hr_include[emp_id];
    gs.info('preethi7 ' + empMmber.title);
}
 
I have got the employee hire date pairs from script include.
But while appending its shows undefined
 
preethigovi_0-1730796575185.png