1

Sitecore 9.0.2, DEF 2.0.1

I have a basic Static Method Value Reader set up:

Static Method Value Reader configuration in Sitecore

It is supposed to call the configured method here:

namespace Custom.Sc.DataExchange.Framework.ValueReaders
{
    public static class StaticMethods
    {
        public static string ReturnEmptyStringIfNull(object[] arguments)
        {
            if (arguments.Length <= 0)
                return string.Empty;

            string input = arguments[0].ToString();

            return input.Equals("NULL", StringComparison.OrdinalIgnoreCase) ? string.Empty : input;
        }
    }
}

But my static method code is never executed. Why not?

1

There are two issues:

  1. The Type With Static Method field needs an assembly-qualified name (e.g. Custom.Sc.DataExchange.Framework.ValueReaders.StaticMethods, Custom.Sc.DataExchange)
  2. The method in Method Name must accept the same parameter type as is coming from your source in the mapping (e.g. string):

    public static string ReturnEmptyStringIfNull(string rawValue)
    {
        if (rawValue == null)
            return null;
    
        return rawValue.Equals("NULL", StringComparison.OrdinalIgnoreCase) ? string.Empty : rawValue;
    }
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.