Add field to request summary page- Client Script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 02:30 PM
Hi everyone,
Can I please get some help with a client script that will change the value of the "short description" to the request_name variable on the portal? I attached a couple screenshots to display what I 'm trying to acheive. (Order guide has the variable request_name that I want to replace the short description on the order guide summary)
I've tried to edit the widget with no luck and was hoping to do this in a client script or script. I'm open to better ideas if anyone has any suggestions.
Thanks so much for any feedback you have!
I believe this should be set as the following:
on change type
sc_cat_item table
field name: short description
script I tried with no luck
function onLoad() {
var requestName = g_form.getValue('request_nameVariable');
if (requestName && g_form.getValue('short_description') == 'Test Catalog Item short description') {
g_form.setValue('short_description', requestName);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 03:25 PM
Hi Gemma4,
Your first screenshot does not show the 'short_description' field, so it is not known what is there. I don't see that field on the item_option_new ("Variables") table.
Also, I don't believe there is a field name present in line:
var requestName = g_form.getValue('request_nameVariable');
Maybe change the above to have 'request_name' without the 'Variable'. Seem more information is needed to assist here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 06:04 PM
Hi @Bert_c1
Attached is the short description field from the sc_cat_item table and I've included where short description is visible on the portal that I'm trying to change to request_name. Let me know your thoughts on what we should change. thanks so much for your help as I'm still new to all the scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 07:57 AM
Hi Gemma4,
I suggest you use the following script logic to test:
function onLoad() {
var requestName = g_form.getValue('request_nameVariable');
alert('requuestName = ' + requestName + ', short_description = ' + g_form.getValue('short_description') +'.');
if (requestName && g_form.getValue('short_description') == 'Test Catalog Item short description') {
g_form.setValue('short_description', requestName);
}
}
Then you can see the values that are used in your "if" statement. I expect to see "undefined" for requestName, since the field is named 'request_name' in your screenshot and not 'request_nameVariable'.
I don't have experience with Service Catalog UI, but I know tables & columns and scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 08:05 PM