/// <summary>
 /// Initializes a new instance of the <see cref="UPConfigExpandCondition"/> class.
 /// </summary>
 /// <param name="condition">The condition.</param>
 /// <param name="alternate">The alternate.</param>
 public UPConfigExpandCondition(UPConfigExpandCondition condition, UPConfigExpandAlternate alternate)
 {
     this.FieldId    = condition.FieldId;
     this.Compare    = condition.Compare;
     this.FieldValue = condition.FieldValue;
     this.Alternate  = alternate;
     this.InitializeDependentFields();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigExpandConditionForQuery"/> class.
        /// </summary>
        /// <param name="condition">The condition.</param>
        /// <param name="crmQuery">The CRM query.</param>
        /// <param name="alternate">The alternate.</param>
        public UPConfigExpandConditionForQuery(UPConfigExpandCondition condition, UPContainerMetaInfo crmQuery, UPConfigExpandAlternate alternate)
            : base(condition, alternate)
        {
            this.ResultPosition = crmQuery?.PositionForField(this.Field) ?? 0;
            if (!this.FieldValue.StartsWith("$cur") && !this.FieldValue.StartsWith("$par"))
            {
                return;
            }

            var dateFieldValue = this.FieldValue.ReplaceDateVariables();

            if (dateFieldValue.StartsWith("$"))
            {
                var replaceValues = UPConditionValueReplacement.SessionParameterReplacements().ValueOrDefault(this.FieldValue);
                if (replaceValues != null && replaceValues.Count > 0)
                {
                    this.FieldValue = replaceValues[0];
                }
            }
            else
            {
                this.FieldValue = dateFieldValue;
            }
        }