Create HR profile or update when user is inserted/Updated

Kachu
Kilo Sage

Hi Community,

I have created Business rule to auto create HR profile when the user record is inserted or updated if there is no HR profile created for the user. below is the business rule .but business rule is not working  Can any one let me know if there are any changes in this code?

Business rule : After create/Update no conditions added  in When to run and Actions. Just Added Advanced script

Thank you.

find_real_file.png

9 REPLIES 9

John Zhang1
Kilo Patron
Kilo Patron

I like to share BR we are using below for your reference:

1) Create HR Profile:

(function executeRule(current, previous /*null when async*/ ) {

var userId = current.sys_id;
checkAndCreateHRProfile(userId);

function checkAndCreateHRProfile(user) {
var gr = new GlideRecord('sn_hr_core_profile');
gr.addQuery('user', user);
gr.query();
if (!gr.next()) {
gs.info('No user is found');
var hrProfile = new hr_Profile();
hrProfile.createProfileFromUser(user);
}
}
})(current, previous);

 

2) Update HR Profile 

find_real_file.png

 

find_real_file.png

 

 

 

If my reply is Helpful/Correct, please mark the answer as correct. This will help others searching for a similar question, and will take the question off the unsolved list.

Best regards,

John

 

 

 

 

 

 

 

 

 

 

Hi Thanks for your response. But i was wondering if we use Flow designer for this ?

Hi @Kachu 

Yes you can use a Flow for this instead of a business rule. Performance wise, a Flow probably has a little more overhead but nothing significant.

You'd want the Flow's trigger to be when the user's record is created or updated (and perhaps meets the additional condition), have it do a check (if statement logic) and then to a ServiceNow Core action to create a record.

 

If this answers your question, please mark the post as solved. So that others looking for something similar can find this thread.

Yes, you can use Flow Designer, but not recommend. 

 

The propose of Flow Designer is below, which is often used to replace the workflow with low code approach 

Flow designer is introduced to configure the process flow without having any developer knowledge. Flow Designer provides a set of ServiceNow core action steps to automate Now Platform processes. It is very useful and user friendly for all ServiceNow users, even for non-technical users and management people. Reduces development cost in business.

Sunny24
ServiceNow Employee
ServiceNow Employee

@Kachu were you able to find the answer for this?