Hi,
Use javascript :)
var link = $getItemValue(ctx, "Link"); var pair = link.split(','); var url = pair[0]; var desc = pair[1];
Thanks,
Mikael Svenson
I am having a similar issue and this code does not solve it.
I am pulling in a URL field with Description like above ("Yahoo.com, My Description"), but the Description portion of the field does not get pulled.
I reference the URL field in my managed property mapping, and then get the item value as follows;
var line1 = $getItemValue(ctx, "Line 1");
but when I attempt to split it, it errors and says split cannot be used on the object. This makes sense since it is creating an object, not a string with getItemValue.
If I console.log the object (line1), it only shows the URL, no description. So it would appear as if during getItemValue it only grabs the URL portion.
If I run the code
var pair = line1.toString().split(',');
then it lets me convert to a string and split it, but since the string didn't appear to have a ", My Description" the second variable is left undefined.
Any idea why it doesn't seem to pull in both the URL and Description for me?
Hi,
I think it might be a Uri prototype object. Try:
line1.get_uri() and line1.get_name() or line1.get_title()
You can always attach a javascript debugger (eg. IE devl toolbar) and examine the object and the methods it provide to find the exact method.
Thanks,
Mikael Svenson
I am having a similar issue and this code does not solve it.
I am pulling in a URL field with Description like above ("Yahoo.com, My Description"), but the Description portion of the field does not get pulled.
I reference the URL field in my managed property mapping, and then get the item value as follows;
var line1 = $getItemValue(ctx, "Line 1");but when I attempt to split it, it errors and says split cannot be used on the object. This makes sense since it is creating an object, not a string with getItemValue.
If I console.log the object (line1), it only shows the URL, no description. So it would appear as if during getItemValue it only grabs the URL portion.
If I run the code
var pair = line1.toString().split(',');then it lets me convert to a string and split it, but since the string didn't appear to have a ", My Description" the second variable is left undefined.
Any idea why it doesn't seem to pull in both the URL and Description for me?
Hey,
Pair is an array :) cause return value of split is an array
you have to say
if line 1 is ("Yahoo.com, My Description")
var _marray = line1.split(',');
even better check for null!!if(_marray && _marray.lenght>0){
var ret_one=line1.split(',')[0];
var ret_two=line1.split(',')[1];
}