want to take employee start date from HR profile

abirakundu23
Mega Sage

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);

6 REPLIES 6

Hi,

 var ga1 = new GlideRecord("sn_hr_core_profile");
    ga1.addQuery("user",current.opened_for);
    ga1.query();
    if(ga1.next()){

Change 2nd line in your to current.opened_for

Try let me know

Thanks

Viswa

hellp @absnow you can try this then 

absnow
  
Mohith Devatte
 • 3h ago3 hours ago Author
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",current.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);


mark the answer correct if this helps you