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

Ravi Gaurav
Giga Sage

Hi @kartikey 

Here's an updated version of the onClick function that sets the hr_service, source, and assigned_to fields:

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

var parameters = {
hr_service: 'Your HR Service Value', // replace with the desired value
source: 'Your Source Value', // replace with the desired value
assigned_to: 'Your Assigned To Value' // replace with the desired value
};

g_aw.openRecord(TABLE_HR_CASE, NEW_RECORD, {
userId: USER,
subjectPersonIdOnCase: USER,
parentTable: PARENT_TABLE,
parentSysId: PARENT_SYS_ID,
parameters: parameters
});
}

 

If I click on the Create HR case  UIaction/button it's redirecting to the case creation page

kartikey_0-1724921435934.png

 

share your Script

No I mean, it's redirecting me to the case creation page, and if i create an HR case from here then its not setting the values we provided.