Client script to change a value

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 onChange() {
    //Type appropriate comment here, and begin script below
g_form.addInfoMessage("client script testing activated2");
    var request_name = g_form.getValue('request_nameVariable');
 
    if (short_description == 'Test Catalog ITem short descirpion') {
        g_form.setValue('short_description', request_name);
 
    }
}ORDER GUIDE.pngclient script.png

 

 

6 REPLIES 6

Harish Bainsla
Kilo Patron
Kilo Patron

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);
}
}

Thank you @Harish Bainsla unfortunately the script recommendation above didn't change the short description value. I added an info message to verify the script was running and it didn't populate. Attached are all the details of the script and variable variable2.PNGupdated Client script.PNGin case there is something minor to change that I am missing. Thanks so much for all your help.

 

sombir5
Tera Contributor

Your requirement :- change short_description  with request_name;

Solution :-

Catalog client script

Type:- onSubmit

 
function onSubmit() {
    //Type appropriate comment here, and begin script below
    var req_for = g_form.getDisplayValue("request_name");
        g_form.setValue("short_description", req_for);
}

 

I hope this will solve your issue. Please mark it as helpful and accept the solution.

Regards,

Sombir

Hi @sombir5 and @Harish Bainsla 

Unfortunately the scripts didn't make any changes. I appreciate the feedback but I thought another way to do this would be to edit the widget. 

I tried to edit the code on this widget to display the request_name

variable from the catalog item. Attached is the variable request_name, the location of where I would like request_name visible and the code I'm trying to edit. Is this possible? I would like short description removed and replaced with the request_name variable.  

 

<!-- {{::item.short_description}}-->
<!-- {{::item.short_description}}-->
<!-- More testing to deterine where short desc is------>
Line 155 item.short description,

 

code.PNGVariable1.PNGWhat to replace.PNG