want to take employee start date from HR profile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 01:15 PM
Hi All,
I take employeement start date from HR profile and set the value in sn_hr_core_case table.
I have wrote code . After/update on case table but it is not working. Please look into this.
(function executeRule(current, previous /*null when async*/) {
// var basecurrency = current.u_currency;
// var split1 = basecurrency.split(' ').slice(0, 1).join(' ');
// gs.addInfoMessage("Check done:" +split1);
gs.addInfoMessage("hello world test");
var ga1 = new GlideRecord("sn_hr_core_profile");
ga1.addQuery("user",name);
ga1.query();
if(ga1.next())
{
current.u_itpend_date=ga1.employment_start_date;
current.update();
}
gs.info("hiiiiiiiiiiiiiiiiii");
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 01:24 PM
hello
if you trying to update the current logged in user employment start date then you might have to change the query
ALSO USING CURRENT.UPDATE() IS NOT A BEST PRACTICE IN AFTER INSERT OR UPDATE BUSINESS RULE SO I HAVE GLIDE RECORDED TO THE CURRENT TABLE AND UPDATED THE FIELD .TRY THE BELOW SCRIPT ONCE
var ga1 = new GlideRecord("sn_hr_core_profile");
ga1.addQuery("user",gs.getUserID());
ga1.query();
if(ga1.next())
{
var gr = new GlideRecord(current.getTableName())
gr.addQuery('sys_id',current.sys_id);
gr.query();
if(gr.next())
{
gr.u_itpend_date=ga1.employment_start_date;
gr.update();
}
})(current, previous);
Hope this helps
MARK THE ANSWER CORRECT IF THIS HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 01:51 PM
Hi
I have write code on "sn_hr_core_case" table.
(function executeRule(current, previous /*null when async*/) {
var ga1 = new GlideRecord("sn_hr_core_profile");
ga1.addQuery("user",gs.getUserID());
ga1.query();
if(ga1.next())
{
var gr = new GlideRecord(current.getTableName());
gr.addQuery('sys_id',current,sys_id);
gr.query();
if(gr.next())
{
gr.u_itpend_date=ga1.employment_start_date;
gr.update();
}
}
})(current, previous);
not running on case table after br. not set employment date on u_itpend_date field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 01:54 PM
hello
(function executeRule(current, previous /*null when async*/) {
var ga1 = new GlideRecord("sn_hr_core_profile");
ga1.addQuery("user",gs.getUserID());
ga1.query();
if(ga1.next())
{
var gr = new GlideRecord('sn_hr_sore_case');
gr.addQuery('sys_id',current.sys_id);
gr.query();
if(gr.next())
{
gr.u_itpend_date=ga1.employment_start_date;
gr.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 09:46 AM
Hi Mohith,
I reruire opened for user employement date not current login user. It is not working.
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage("hello world");
var ga1 = new GlideRecord("sn_hr_core_profile");
ga1.addQuery("user","opened_for");
ga1.query();
if(ga1.next())
{
var gr = new GlideRecord('sn_hr_core_case_global_mobility');
gr.addQuery('sys_id',current.sys_id);
gr.query();
if(gr.next())
{
gr.u_itpend_date=ga1.employment_start_date;
gr.update();
}
}
gs.addInfoMessage("hello world");
})(current, previous);