2

Sitecore Version: 9.1 Update 1

I am trying to retrieve all email campaigns in a non-Sitecore context. To do that, First I Constructed the definition manager in a non-Sitecore context:

private static CampaignDefinitionManager CreatecampaignManager()
    {
        var loggerFactory = new Microsoft.Extensions.Logging.LoggerFactory();
        CertificateHttpClientHandlerModifierOptions options = CertificateHttpClientHandlerModifierOptions.Parse(ConfigurationManager.AppSettings["thumbPrint"]);
        IHttpClientHandlerModifier[] handlers = { new CertificateHttpClientHandlerModifier(options) };
        var refDataClient = new ReferenceDataHttpClient(
            new DefinitionEnvelopeJsonConverter(),
            new Uri(ConfigurationManager.AppSettings["xConnectUrl"]),
            handlers,
            new Logger<ReferenceDataHttpClient>(loggerFactory)
        );
        var repo = new CampaignDefinitionReferenceDataRepository (
            refDataClient,
            new CampaignDataConverter(),
            new GuidMonikerConverter(),
            new DefinitionOperationResultDiagnostics()
        );
        var def = new NotConfiguredDefinitionFieldLabelResolver();
        var services = new ServiceCollection();
        services.AddSingleton<ITaxonomyManagerProvider, TaxonomyManagerProvider>();
        services.AddSingleton<ITaxonomyClassificationResolver<ICampaignActivityDefinition>, DefaultClassificationResolver<ICampaignActivityDefinition>>();
        services.AddSingleton<FieldTaxonomyMap<ICampaignActivityDefinition>>();
        IServiceProvider serviceProvider = services.BuildServiceProvider();
        var classificationResolver = serviceProvider.GetRequiredService<ITaxonomyClassificationResolver<ICampaignActivityDefinition>>();
            return new CampaignDefinitionManager(
            repo,
            classificationResolver,
            def,
            new NotSupportedSearchProvider<ICampaignActivityDefinition>(),
            new ActivationRetryingObservableFeed<ICampaignActivityDefinition>(new Logger<ActivationRetryingObservableFeed<ICampaignActivityDefinition>>(loggerFactory)),
            new DummyDeletecampaignObservableFeed(),
            new DefaultDefinitionManagerSettings()
        );
    }

And then using this manager, calling getAll method:

ResultSet<DefinitionResult<ICampaignActivityDefinition>> campaigns = manager.GetAll(new CultureInfo("da"), new RetrievalParameters<ICampaignActivityDefinition, string>());

But after doing all this, getting this error:

    Unhandled Exception: System.InvalidOperationException: The marketing definition field label resolver has not been configured
   at Sitecore.Marketing.Definitions.NotConfiguredDefinitionFieldLabelResolver.get_FieldList()
   at Sitecore.Marketing.Definitions.DefinitionManagerBase`2.InitializeLabelResolver(IDefinitionFieldLabelResolver definitionFieldLabelResolver)
   at Sitecore.Marketing.Definitions.DefinitionManagerBase`2..ctor(IDefinitionRepository`1 repository, ITaxonomyClassificationResolver`1 classificationResolver, IDefinitionFieldLabelResolver definitionFieldLabelResolver, IDefinitionSearchProvider`1 searchProvider, Boolean isReadOnly, IActivationObservableFeed`1 activationFeed, IDeleteDefinitionObservableFeed`1 deleteDefinitionFeed)
   at Sitecore.Marketing.Definitions.Campaigns.CampaignDefinitionManager..ctor(ICampaignDefinitionRepository repository, ITaxonomyClassificationResolver`1 classificationResolver, IDefinitionFieldLabelResolver definitionFieldLabelResolver, IDefinitionSearchProvider`1 searchProvider, IActivationObservableFeed`1 activationFeed, IDeleteDefinitionObservableFeed`1 deleteDefinitionFeed, IDefinitionManagerSettings settings)

Any idea, how to resolve this error to get all email campaigns in a non-Sitecore context.

2

You're defining the DefinitionFieldLabelResolver as an NotConfiguredDefinitionFieldLabelResolver, which will throw an InvalidOperationException for each method that it implements

It should be enough to change the type from NotConfiguredDefinitionFieldLabelResolver to EmptyDefinitionFieldLabelResolver. This class can be found in the Sitecore.Xdb.MarketingAutomation.Definitions namespace (Sitecore.Xdb.MarketingAutomation.dll).

1
  • Thanks Maarten, That worked for me :) Apr 2 at 8:35

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.