How to set a default choice for any field on a HR Case when a Chat Agent clicks on "Create HR Case"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2023 01:09 AM
As a Chat Agent, when I create a HR Case for a user by clicking "Create HR Case" in the Agent Workspace, I want to set the default value of the Source field of HR Case record to "Chat".
Please guide me how to achieve this.
Thanks 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2023 01:23 AM
Try editing the existing "Create HR Case" UI Action or create a new ui action with below script:
// Set the default value for the "Source" field to "Chat"
current.source = 'Chat';
// Create the HR Case
var newHRCase = new GlideRecord('hr_case');
newHRCase.initialize(); // Initialize a new HR Case record
newHRCase.source = 'Chat'; // Set the "Source" field of the new HR Case record to "Chat"
// Insert the new HR Case record
var newHRCaseID = newHRCase.insert();
// Redirect to the newly created HR Case form
action.setRedirectURL('/nav_to.do?uri=hr_case.do?sys_id=' + newHRCaseID);
Hope this helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2023 01:56 AM
Hi @msd93, thanks for the reply
Below is the code present in existing "Create HR Case" UI Action. Can we achieve my requirement somehow here only?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2023 02:03 AM - edited ‎09-21-2023 02:03 AM
Try adding a variable like var source = 'chat';//prvoide value of chat
and modify below line by appending the source variable:
g_aw.openRecord(TABLE_HR_CASE, NEW_RECORD, {userId: USER, source:source,subjectPersonIdOnCase: USER, parentTable: PARENT_TABLE, parentSysId: PARENT_SYS_ID});
Hope this works.