We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

updating Create HR Case UI action in interaction record

kartikey
Tera Contributor

Hi Everyone,

There's a "Create HR Case" ui action on interaction record, which has a Workspace client script:

 

function onClick() {
    var USER = g_form.getValue('opened_for');
    var NEW_RECORD = '-1';
    var TABLE_HR_CASE = 'sn_hr_core_case';
    var PARENT_TABLE = g_form.getTableName();
    var PARENT_SYS_ID = g_form.getUniqueValue();
    g_aw.openRecord(TABLE_HR_CASE, NEW_RECORD, {userId: USER, subjectPersonIdOnCase: USER, parentTable: PARENT_TABLE, parentSysId: PARENT_SYS_ID});
}



As far as i've looked into it 'g_aw.openRecord' is used to open an existing record, then how is this button creating a new record?

Further my requirement is that when a new record is created i wish to set few field values to it example, HR service, Source, assigned to etc. how do i implement this or update the UI action ?
Can someone please help me with this?

Thanks,
Kartikey

5 REPLIES 5

Hi @Ravi Gaurav ,

Can you please specify where this script exists?