To display values of Multi Line Text in Separate Lines

rishabh31
Mega Sage

Dear Team,

I have a Multi Row variable set Product Details in a catalog item under which there are 2 variables, one is Product Name Type-Single Line Text and the other Variable Product IDs of Multi Line Text type, here when a user click on Add button to insert the details and enters space-separated values in Multi Line Text type variable Product IDs, and click on the button Add, and then in form, it currently displays as as shown in attached screenshot. 
But I want this to be displayed in Separate lines in the form when added.
like as shown in the attached screenshot
To achieve this I wrote an onload catalog client script (shown below and also attached) in this MVRS variable set, which is

 

function onLoad() {
    //Type appropriate comment here, and begin script below
    var major = g_form.getValue('product_id_s');
	var value1 = major.split(' ');
    alert("item length:" + value1.length);
    var bs = [];
    var resp = '';
    for (var i = 0; i < value1.length; i++) {
        resp = value1[i].split('\n');
        bs.push(resp[0]);
    }
	g_form.setValue('product_id_s', bs.join('\n'));
}

 

But this is not working. Please help to achieve this. The use case is to differentiate each product ID into separate lines to give better understanding and clarity. I tried the HTML type variable but mvrs does not allow the HTML type variable.
 
Thanks in advance.
5 REPLIES 5

rishabh31
Mega Sage

@OlaN Sir or anyone who can help on this.

OlaN
Giga Sage
Giga Sage

Hi,

I had a look at this requirement, and I have some trouble understanding.

If you want to show line separated values in the multi-row-variable-set-widget, you will have to make modification on the widget itself. I would not recommend that approach.

When I tried for myself, I noticed that regardless if the user enters a text that is line separated or space separated, the widget displays the value in the same manner, but when editing the input, one can see that the line breaks are stored.

So I would try using it as is, and don't mess around with how it is displayed after the input is entered.

 

See attached images for clarification.

mrvs-multi-line-text-1.pngmrvs-multi-line-text-2.png

@OlaN sir, Thanks for giving the useful information. I understand what you want to conveyed.

 

So sir is there any alternative way to do something like when user enters the values it will displayed in separate lines.

 

Thanks

An alternate way to show the lines with a multi-line input, is to use that variable separate (not included in an MRVS).