Gravatar for fcote@coveo.com

Question by fcote, Nov 9, 2016 11:16 AM

C# Conversion Script to Map Sysuri on External Sources with Coveo for Sitecore 3.0

I am getting issue in conversion script, am trying to map “sysuri” to “RelativeURL” field, but its always executing else part(assigning “#” value), Please advise. Is there any other way to map sysuri field to any other custom field?

using System; 
using System.Linq; 
using Coveo.CES.Interops.COMCoveoConvertersWrappers; 

namespace mylfcom 
{ 
    public class TypePostConversion : Coveo.CES.DotNetConverterLoader.CustomConverter {
        public override void RunPostConverter(PostConversion p_PostConversion, 
                                              DocumentInfo p_DocumentInfo) { 
            string uri = ""; 
            if (p_DocumentInfo.Fields().Cast<String>().Any(w => w == "sysuri")) { 
                uri = p_DocumentInfo.GetFieldValue("sysuri") as String; 
            } else { 
                uri = "#"; 
           } 
           p_DocumentInfo.SetFieldValue("RelativeURL", uri); 
        } 
    }
}
1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Nov 9, 2016 3:21 PM

Hi,

"sysuri" is not a metadata on the document to process. @sysuri is a field set from the DocumentInfo.URI property after the conversion is done.

You should do something like (I didn't tried the code):

if (!String.IsNullOrEmpty(p_DocumentInfo.URI as String)) { 
    uri = p_DocumentInfo.URI as String;
}

I hope this helps

Jeff

Gravatar for bkumar@littelfuse.com

Comment by Bharath, Nov 10, 2016 8:10 AM

Hi Jeff,

It (p_DocumentInfo.URI) worked. Thanks a lot.

Regards, Bharath

Ask a question