how to set values using UI action for agent workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2023 01:52 PM
I have created a UI action to create a Normal change from incident form on agent workspace, the UI action works fine. But I want to set value on incident with new change created and associate the change with incident from which change created.
Below is the code which is used workspace client script
function onClick(g_form) {
var result = g_form.submit('create_normal_chg_ws');
if (!result) {
return;
}
result.then(function() {
var params = {};
params.sysparm_parent_table = "incident";
params.sysparm_parent_sys_id = g_form.getUniqueValue();
params.rfc= g_form.getUniqueValue(); //set change on incident
g_aw.openRecord('change_request',-1,params);
});
}
with the help of params nothing is set for fields but I can see these values on URL.
Any help much appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2023 02:14 AM
Ok, I am not sure if there is a way how we can set values.
I was thinking this could do that, when I tried it sets values as well but having hard time to set the value of rfc field on incident or parent field on change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2023 01:36 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 along the following lines (at least for the part where you want to set a value on the record being opened):
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.