populating short description instead of item name

jean-pauldehaas
Tera Guru

Hi,

 

i have a requirement where if a catalog item has a variable called short description it should display this instead of the item name on the portal.

i got it working partially , its only not displaying one 1 part:

jeanpauldehaas_0-1707923584095.png

 

My other question is, the script i used works if i set it for 1 particular item but how can i do this for all items ?

this is my BR:

(function executeRule(current, previous /*null when async*/) {

if (current.cat_item.name == '') {

current.short_description = current.variables.short_description;

}
})(current, previous);
1 ACCEPTED SOLUTION

Weird
Mega Sage

Well, for all the catalog items your script can simply check for 

if(current.variables.short_description){
current.short_description = current.variables.short_description;
}


This would check if the variable exists and it would overwrite the short description always without care for which item the BR is run against.

Now for portal the widget is actually pulling certain information from the related record. If you really wanted to replace "item" with the "short description", then you'd need to do some rather hefty modification to the widget so that in those cases instead of "item" fields value it would show the short description. Item is the name of the catalog item.
But honestly just from this description it seems like a bad idea. I can't see why you'd want to do that. So that the end user doesn't see the catalog items name? They'd still see that when selecting the form and the short description is already shown in two places so the end user shouldn't be confused about that.

To actually do it you'd either have to mess with the object on server side or modify the HTML side to display a different label for certain element, but it's quite a lot of work. Easiest thing to do is to replace "item" with "short_description" in the instance options or server script, if it's specified there, but it would affect everything and show, for example, "Short description the_value_from_short_description" instead of "Item the_item_value".
You'd still probably want to keep showing "Item" instead and probably would like to keep the item value as well for the other catalog items, so you'd still be forced to do even more changes to the script.

View solution in original post

2 REPLIES 2

Weird
Mega Sage

Well, for all the catalog items your script can simply check for 

if(current.variables.short_description){
current.short_description = current.variables.short_description;
}


This would check if the variable exists and it would overwrite the short description always without care for which item the BR is run against.

Now for portal the widget is actually pulling certain information from the related record. If you really wanted to replace "item" with the "short description", then you'd need to do some rather hefty modification to the widget so that in those cases instead of "item" fields value it would show the short description. Item is the name of the catalog item.
But honestly just from this description it seems like a bad idea. I can't see why you'd want to do that. So that the end user doesn't see the catalog items name? They'd still see that when selecting the form and the short description is already shown in two places so the end user shouldn't be confused about that.

To actually do it you'd either have to mess with the object on server side or modify the HTML side to display a different label for certain element, but it's quite a lot of work. Easiest thing to do is to replace "item" with "short_description" in the instance options or server script, if it's specified there, but it would affect everything and show, for example, "Short description the_value_from_short_description" instead of "Item the_item_value".
You'd still probably want to keep showing "Item" instead and probably would like to keep the item value as well for the other catalog items, so you'd still be forced to do even more changes to the script.

@Weird thanks this was really helpfull.

 

the goal was to make it easier for end users to recognize the correct item by short description if they submitted like 10 of them, but i agree the first step should be enough.