HRSD Agent Workspace g_aw.openrecord() question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 09:53 AM - edited 03-23-2023 10:08 AM
Hello all,
Is it possible to auto populate a couple of fields on the target record with the aw_openRecord() ?
I've spotted that an OOTB ui action is already doing that (Create HR Case on the Interactions table):
Here's the OOTB Workspace Client Script:
function onClick(g_form) {
var USER = g_form.getValue('opened_for');
var NEW_RECORD = '-1';
var TABLE_HR_CASE = 'sn_hr_core_case';
g_aw.openRecord(TABLE_HR_CASE, NEW_RECORD, {userId: USER, subjectPersonIdOnCase: USER});
}
But when I try to add more fields it doesn't auto populate like the Opened For and Subject Person.
Anyone had this issue before and found a solution?
Thanks.
- Labels:
-
HR Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2023 03:46 AM
Hi @DrDinu ,
Please refer to the syntax and the examples : https://docs.servicenow.com/en-US/bundle/utah-api-reference/page/app-store/dev_portal/API_reference/...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2023 10:09 AM
Thank you but that doesn't answer the question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 04:47 PM
I have the same issue, and I think unfortunately it's logic on the case_creation UI page that handles the opened for and subject person population. The UI page doesn't have any logic to handle populating any other fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 01:33 PM
I know this is likely too late to help with your specific issue, but this may help others who are looking for it in the future. The solution to your ask is as follows:
Utilize the query functionality in your openrecord statement. This is based on the assumption that you are starting from a record you want to duplicate ... but should work with static values in place of the g_form.getValue.
g_aw.openRecord(<TABLE NAME HERE>, "-1", { query: "parent=" + g_form.getValue('parent') + "^field2=" + g_form.getValue('field2') + "^field3=" + g_form.getValue('field3') + "^field4=" + g_form.getValue('field4')});
I'm sure there is a length limit on how long the query string ends up resolving to, but I've used this with reference fields and string fields with no problems. Note the "^" at the beginning of the 2nd, 3rd and 4th query clauses.