private void updateOtherSiblings(PXCache sender, object row)
        {
            bool needRefresh = false;

            if (_parentAttribute == null)
            {
                return;
            }
            PXFieldState state = (PXFieldState)sender.GetStateExt(row, _FieldName);

            if (state.DataType != typeof(bool))
            {
                return;
            }
            if ((bool?)sender.GetValue(row, _FieldName) == false)
            {
                return;
            }
            foreach (object sibling in PXParentAttribute.SelectSiblings(sender, row, _parentAttribute.ParentType))
            {
                if (!sender.ObjectsEqual(sibling, row))
                {
                    if ((bool?)sender.GetValue(sibling, _FieldName) == true)
                    {
                        sender.SetValue(sibling, _FieldName, false);
                        sender.Update(sibling);
                        needRefresh = true;
                    }
                }
            }

            if (needRefresh)
            {
                foreach (var kvp in sender.Graph.Views)
                {
                    PXView view = kvp.Value;
                    if (_BqlTable.IsAssignableFrom(view.GetItemType()))
                    {
                        view.RequestRefresh();
                    }
                }
            }
        }
        private IEnumerable <ApproveInfo> ProcessLevel(Table item, int?assignmentMap, PXResultset <EPRule> rules)
        {
            foreach (EPRule rule in rules)
            {
                if (rule.RuleID == null)
                {
                    continue;
                }

                path.Add(rule.RuleID.Value);

                bool isSuccessful  = true;
                var  filteredItems = ExecuteRule(item, rule, ref isSuccessful);


                Guid?OwnerID     = null;
                int? WorkgroupID = rule.WorkgroupID;

                switch (rule.RuleType)
                {
                case EPRuleType.Direct:

                    if (!isSuccessful || (filteredItems != null && filteredItems.Count == 0))
                    {
                        continue;
                    }

                    OwnerID = rule.OwnerID;

                    FillOwnerWorkgroup(ref OwnerID, ref WorkgroupID);

                    if (OwnerID == null && WorkgroupID == null)
                    {
                        continue;
                    }

                    yield return(new ApproveInfo()
                    {
                        OwnerID = OwnerID,
                        WorkgroupID = WorkgroupID,
                        RuleID = rule.RuleID,
                        StepID = rule.StepID,
                        WaitTime = rule.WaitTime
                    });

                    break;

                case EPRuleType.Document:

                    if (rule.OwnerSource == null || (filteredItems != null && filteredItems.Count == 0))
                    {
                        continue;
                    }

                    PXView lineView    = null;
                    PXView primaryView = null;
                    Type   viewType    = null;
                    try
                    {
                        var s        = rule.OwnerSource;
                        var viewName = s.Substring(s.LastIndexOf("(") + 1, s.IndexOf(".") - (s.LastIndexOf("(") + 1));

                        if (String.Equals(viewName, processGraph.PrimaryView, StringComparison.InvariantCultureIgnoreCase))
                        {
                            primaryView = processGraph.Views[viewName];
                            viewType    = primaryView.GetItemType();
                        }
                        else
                        {
                            lineView = processGraph.Views[viewName];
                            viewType = lineView.GetItemType();
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }


                    bool queryContainsDetails = filteredItems != null && filteredItems.Count > 0 && ((PXResult)filteredItems[0])[viewType] != null;

                    var arrayToIterate = queryContainsDetails
                                                        ? filteredItems
                                                        : lineView?.SelectMulti() ?? primaryView.Cache.Current.SingleToList() ?? filteredItems;

                    foreach (object filteredItem in arrayToIterate)
                    {
                        if (filteredItem is PXResult)
                        {
                            var line = ((PXResult)filteredItem)[viewType];
                            processGraph.Caches[viewType].Current = line;
                        }
                        else
                        {
                            processGraph.Caches[viewType].Current = filteredItem;
                        }

                        string code = PXTemplateContentParser.Instance.Process(rule.OwnerSource, processGraph, viewType, null);

                        EPEmployee emp =
                            PXSelect <
                                EPEmployee,
                                Where <EPEmployee.acctCD, Equal <Required <EPEmployee.acctCD> > > >
                            .SelectWindowed(this, 0, 1, code);

                        OwnerID = emp != null ? emp.UserID : GUID.CreateGuid(code);

                        FillOwnerWorkgroup(ref OwnerID, ref WorkgroupID);

                        if (OwnerID == null && WorkgroupID == null)
                        {
                            continue;
                        }

                        yield return(new ApproveInfo()
                        {
                            OwnerID = OwnerID,
                            WorkgroupID = WorkgroupID,
                            RuleID = rule.RuleID,
                            StepID = rule.StepID,
                            WaitTime = rule.WaitTime
                        });
                    }

                    break;

                case EPRuleType.Filter:

                    if (filteredItems == null || filteredItems.Count == 0)
                    {
                        continue;
                    }

                    List <EPRuleBaseCondition> conditions =
                        PXSelectReadonly <EPRuleEmployeeCondition,
                                          Where <EPRuleEmployeeCondition.ruleID, Equal <Required <EPRule.ruleID> > > >
                        .Select(this, rule.RuleID)
                        .Select(_ => (EPRuleBaseCondition)_)
                        .ToList();

                    if (conditions.Count == 0)
                    {
                        break;
                    }

                    foreach (var approveInfo in GetEmployeesByFilter(item, rule, conditions))
                    {
                        yield return(approveInfo);
                    }

                    break;
                }

                if (rule.RuleID != null)
                {
                    if (path.Contains(rule.RuleID.Value))
                    {
                        continue;
                    }

                    foreach (var approveInfo in ProcessLevel(item, assignmentMap, PXSelectReadonly <EPRule> .Search <EPRule.ruleID>(this, rule.RuleID)))
                    {
                        yield return(approveInfo);
                    }
                }

                PXResultset <EPRule> result = PXSelectReadonly <
                    EPRule,
                    Where <
                        EPRule.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> > >,
                    OrderBy <
                        Asc <EPRule.sequence> > > .Select(this, assignmentMap);

                foreach (var approveInfo in ProcessLevel(item, assignmentMap, result))
                {
                    yield return(approveInfo);
                }
            }
        }