UI Action to specific General IT request copy description,short description and caller to variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 07:58 AM
I have a request for a ui action from incident form same conditions as Create Request that is ootb. However they specifically want it to point to one catalog item and that that catalog item generate the description, short description and caller fields from incident to the General IT catalog variable Requestor = caller_id, variable short_description = short_description and variable description = description.
i have reviewed some documentation on it but still confused as to why its not working. my script is below.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 11:34 AM
Hi @Ryan O_
Step 1: Creating the UI Action
1. Navigate to System Definition > UI Actions.
2. Create New UI Action with the following attributes:
- Name: Populate and Open Catalog Item (or any meaningful name)
- Table: Incident
- Action Name: A unique identifier for the action, like open_catalog_item
- Form Button: Checked (to make it appear as a button on the form)
- Client: Checked, because you’ll be using a client-side script to redirect the user’s browser
- Condition: Copy the conditions from the OOTB “Create Request” UI action if you want to mirror its availability
3. Script:
Here’s an script.
Note: Replace YOUR_CATALOG_ITEM_SYS_ID, requestor, short_description, and description with the actual Sys ID and variable
var catalogItemId = ‘YOUR_CATALOG_ITEM_SYS_ID’;
var currentCallerId = g_form.getValue(‘caller_id’);
var currentShortDescription = g_form.getValue(‘short_description’);
var currentDescription = g_form.getValue(‘description’);
// Encode the variables’ values to be URL-safe
var requestorVar = encodeURIComponent(currentCallerId);
var shortDescriptionVar = encodeURIComponent(currentShortDescription);
var descriptionVar = encodeURIComponent(currentDescription);
// Construct the redirect URL
var url = ‘/com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=’ + catalogItemId;
url += ‘&sysparm_variable_requestor=’ + requestorVar;
url += ‘&sysparm_variable_short_description=’ + shortDescriptionVar;
url += ‘&sysparm_variable_description=’ + descriptionVar;
// Redirect the user to the Catalog Item form with prepopulated fields
g_navigation.open(url, ‘_blank’);
PLEASE MARK THIS AS HELPFUL AND ACCEPTED SOLUTION IF THIS HELPS YOU. THIS WILL HELP BOTH ME AND THE COMMUNITY
THANKS AND REGARDS
DEEPAK SHARMA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 11:47 AM - edited 03-28-2024 11:56 AM
updated and tested, it seems the client field when 'checked' goes to this search page after making those updates. with Null displaying as the value attached screenshot.
besides where you explicitly have catalogItemID or sys id labeled where else do i need to add the sys id you list description,short_description and requestor are correct for the variables.
form button did not do anything for some reason but not a big issue as this would still be the right click 'form context menu' selection.