3

I have a custom predicate which is used as a rule for a Custom Listener in Marketing Automation. It checks the value of a property in a custom event and, when it evaluates to True the journey proceeds with no issues.

When it evaluates to False, the contact appears to get stuck in the Custom Listener event and fails to move down the No path of the decision point. The contact goes through the first time, hits the False outcome, but does not then continue on the path. On subsequent retries, the contact throws an error on the following line of code:

var interactions = context.Fact<Interaction>();

Prior to this, it successfully loads the contact from the context.

This happens repeatedly on the evaluation of the predicate in the Custom Listener and the contact fails to then move through the No path of the journey.

What would cause this and how can I get the contact to move through the False/No path of the custom listener ?

Platform is Sitecore 9.1 initial release, local dev.

UPDATE 1: it looks like the contact passes through the predicate, returns false to the Custom Listener, and then for some reason passes through again but with no interaction data. If I skip over it with a Try/Catch, the next Activity Type step fails when it tries to retrieve interactions.

UPDATE 2: Error thrown is "No rule fact resolver could be found for Type:'Sitecore.XConnect.Interaction', Role:''."

Predicate code is:

public class PipelineStage : ICondition
    {
        public string PipelineStageCode { get; set; }

        public StringOperationType Comparison { get; set; }

        // Evaluates condition for single contact
        public bool Evaluate(IRuleExecutionContext context)
        {
            try
            {
                if (PipelineStageCode != null && Quote.IsValidPipelineStage(PipelineStageCode))
                {
                    var contact = context.Fact<Contact>();
                    var interactions = context.Fact<Interaction>();

                    if (interactions != null && interactions.Events != null && interactions.Events.Any(e => e.DefinitionId.Equals(Quote.EventDefinitionId)))
                    {
                        Quote quoteEvent = (Quote)interactions.Events.Where(e => e.DefinitionId.Equals(Quote.EventDefinitionId)).OrderByDescending(e => e.Timestamp).FirstOrDefault();
                        if (quoteEvent != null && quoteEvent.PipelineStage.ToString().Equals(PipelineStageCode))
                            return true;
                    }
                }
                return false;
            }
            catch (Exception ex) {
                return false;
            }
        }
    }
2

To get around this issue I retrieved the interactions from the Contact via the code below. If anyone can explain why, that would be helpful, but this should get you out of trouble.

Contact contact = context.Fact<Contact>((string)null);
if (contact != null && contact.Interactions != null && contact.Interactions.Any())
{
  //do stuff
  return true;
}
| improve this answer | |

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.