- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 05:02 AM
Hi All,
I have a query in service catalog item. I have two multiline text field. In first field i am putting some values like 'test1-123'
'test2-456'
test3-789'
Now I want to split all these values by '-'. I want to set 'test1', 'test2' and 'test3' in one multi line text and '123' '456' '789' in another multi line text field.
I am able to split all the values but the problem is that I am not able to store all left side value(test1, 'test2', test3') in the first multi line text field
and right side value('123','456','789') in second multi line text field.
Only last value which is 'test3-789' showing. that means 'test3' is coming on first multi line text field and '789' is on second multi line.
I have done this coding in client script:-
function onLoad() {
var major = g_form.getValue('text1');
var value1=major.split('\n');
var value2=major.split(',');
alert("item length:"+value1.length);
for (var i=0; i < value1.length; i++) {
alert("Display value is: " + value1[i]);
alert("resp value length:"+value1[i].length);
resp = value1[i].split('-');
var bs = resp[0];
var ans1 = resp[1];
g_form.setValue('text1', resp[0]);
g_form.setValue('text2', resp[1]);
}
please help to resolve this problem. Thanks in advance.
Regards,
Payal Bharti
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 05:21 AM
Below should work
function onLoad() {
var major = g_form.getValue('text1');
var value1=major.split('\n');
var value2=major.split(',');
alert("item length:"+value1.length);
var bs=[];
var ans1=[];
var resp='';
for (var i=0; i < value1.length; i++) {
resp = value1[i].split('-');
bs.push(resp[0]);
ans1.push(resp[1]);
}
g_form.setValue('text1', bs);
g_form.setValue('text2', ans1);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 05:56 AM
g_form.setValue('text1', bs.join('\n');
g_form.setValue('text2', ans1.join('\n'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2016 06:01 AM
Thanks Srinivas
It is working