
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 01:28 AM
Hi SN-community!
One of our customers have a request to update the HR Profile when a HR-profile change request is submitted through the HR Portal.
As of now the record producer create a HR Case record using the script includes that are provided out of the box (the record producer is mapped to the HR case). A case is created with some tasks to update other systems when a change is created from the portal.
However, the customer also wish the changes made to also apply to the HR Profile of the relevant user.
I tried to do this using the record producer script, but I am not sure if that is the correct place to do GlideRecord queries? Is there a more optimal solution?
This is what I tried so far:
var hrServiceU = new sn_hr_core.hr_ServicesUtil(current, gs);
hrServiceU.createCaseFromProducer(producer,cat_item.sys_id); //calls the case script include
updateRecord();
function updateRecord() {
var opened_for = producer.opened_for;
gs.info("Opened for :" + opened_for);
var core_profile = new GlideRecord('sn_hr_core_profile');
core_profile.addQuery('user', opened_for);
core_profile.query();
if(core_profile.next()) {
core_profile.u_bank_name = producer.u_bank_name;
core_profile.u_branch = producer.u_branch;
core_profile.u_account_number = producer.u_account_number;
core_profile.u_iban_number = producer.u_iban_number;
core_profile.u_swift = producer.u_swift;
core_profile.u_a_c_name = producer;
core_profile.update();
}
}
This solution appears to not do anything at all - and I'm not too sure where to go next.
Cheers
Sondre Braathen
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 05:42 AM
I found the solution - I used the wrong query parameter (name instead of user) and had to use object.setValue to set the value
var opened_for = producer.opened_for.toString();
var core = new GlideRecord('sn_hr_core_profile');
core.addQuery('user', opened_for);
core.query();
if(core.next()) {
core.setValue('u_branch', producer.u_branch.toString());
core.setValue('u_bank_name', producer.u_bank_name.toString());
core.setValue('u_account_number', producer.u_account_number.toString());
core.setValue('u_iban_number', producer.u_iban_number.toString());
core.setValue('u_swift', producer.u_swift.toString());
core.setValue('u_a_c_name', producer.u_a_c_name.toString());
core.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 03:20 AM
Hi,
Since all the fields are of record producer are mapped with HR Case try with the business rule on hr_case table to do your query or update.
Regards,
Adarsha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 03:51 AM
Hi Adarsha, thank you for your response.
The fields are not mapped, only the opened_for reference field is used in the HR Case - the rest of the variables on the record producer is printed in the description of the HR Case by an OOB script include (HR_CaseUtils). This would mean that this is hard to do with a business rule, as the variables are not saved to the sn_hr_core_case-object. Or am I wrong?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 05:42 AM
I found the solution - I used the wrong query parameter (name instead of user) and had to use object.setValue to set the value
var opened_for = producer.opened_for.toString();
var core = new GlideRecord('sn_hr_core_profile');
core.addQuery('user', opened_for);
core.query();
if(core.next()) {
core.setValue('u_branch', producer.u_branch.toString());
core.setValue('u_bank_name', producer.u_bank_name.toString());
core.setValue('u_account_number', producer.u_account_number.toString());
core.setValue('u_iban_number', producer.u_iban_number.toString());
core.setValue('u_swift', producer.u_swift.toString());
core.setValue('u_a_c_name', producer.u_a_c_name.toString());
core.update();
}