The CreatorCon Call for Content is officially open! Get started here.

Add field to request summary page- Client Script?

Gemma4
Mega Sage

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);
}
}variable2.PNGORDER GUIDE.png

11 REPLIES 11

Bert_c1
Kilo Patron

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.

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. 

 

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.

Thank you so much for all the help. I don't have much experience scripting and this has been a challenge. I added your script but there was not any alert messages visible when I submitted the request. In addition, I even added an info message with no luck. any other suggestions