如何在 Dynamics CRM VOC 中获取调查实体和响应路由之间的关系?

How to get a relation between the survey entity and the response routing in Dynamics CRM VOC?

我正在开发一款软件,该软件从使用 this technique 导航调查的 Dynamics CRM 中收集 "questions"。

到目前为止,我看到的任何属性都不能用于在问题和我得到的响应路由集合之间创建 link。

是否可以将ressponrouting连接到它所听的问题? 那么是否也可以将它与它管理的问题联系起来?

到目前为止我找不到任何连接属性,我可以用它来识别问题and/or responserouting。

此功能收集问题

    private static DataCollection<Entity> GetQuestions(Guid _surveyId)
    {
        // Find survey question responses
        QueryExpression questionQuery = new QueryExpression
        {
            EntityName = "msdyn_question",
            ColumnSet = new ColumnSet(true),
            Criteria = new FilterExpression
            {
                Conditions =
                {
                    new ConditionExpression
                    {
                        AttributeName = "msdyn_surveyid",
                        Operator = ConditionOperator.Equal,
                        Values = {_surveyId}
                    }
                }
            }
        };
        return connection.service.RetrieveMultiple(questionQuery).Entities;
    }

这个函数returns ResponseRouting对象:

    private static DataCollection<Entity> GetRouting(Guid _surveyId, string query)
    {
        // Find survey question responses
        QueryExpression questionQuery = new QueryExpression
        {
            EntityName = query,
            ColumnSet = new ColumnSet(true),
            Criteria = new FilterExpression
            {
                Conditions =
                {
                    new ConditionExpression
                    {
                        AttributeName = "msdyn_survey",
                        Operator = ConditionOperator.Equal,
                        Values = {_surveyId}
                    }
                }
            }
        };
        return connection.service.RetrieveMultiple(questionQuery).Entities;
    }

我确实得到了相应的 ResponseRouting 对象,但是我找不到关于在哪里以及如何格式化前面问题的任何参考点。

这都是基于c#代码,我需要能够通过代码到达它,否则它没有帮助...

调查问题和响应路由之间没有直接关系。但是在Response routing record中,添加Condition的时候要选择Question。

所以需要的link在响应路由和问题的条件记录之间。

Response routing rule has 3 parts:
General Tab (contains the name of the rule and name of the survey)
Conditions Tab ( contains the conditions to be met on the survey)
Actions (contains the actions to be taken when the conditions are met)

Read more.

更新:

响应条件与问题、响应路由和调查有 N:1 关系。

因为你已经有了问题列表,遍历每个问题并使用下面的方法你可以获得相关的响应路由。

private static DataCollection<Entity> GetRoutingConditions(Guid _questionId, Guid _surveyId)
{
    // Find Routing conditions
    QueryExpression routingConditionQuery = new QueryExpression
    {
        EntityName = "msdyn_responsecondition",
        ColumnSet = new ColumnSet(true),
        Criteria = new FilterExpression
        {
            Conditions =
            {
                new ConditionExpression
                {
                    AttributeName = "msdyn_questionid",
                    Operator = ConditionOperator.Equal,
                    Values = {_questionId}
                }
            }
        },
        LinkEntities =
        {
            new LinkEntity
            {
                LinkFromEntityName = "msdyn_responsecondition",
                LinkToEntityName = "msdyn_responserouting",
                LinkFromAttributeName = "msdyn_responseroutingid",
                LinkToAttributeName = "msdyn_responseroutingid",
                LinkCriteria =
                {
                    Filters =
                    {
                        new FilterExpression
                        {
                            FilterOperator = LogicalOperator.And,
                            Conditions =
                            {
                                new ConditionExpression("msdyn_surveyid", ConditionOperator.Equal, _surveyId)
                            }
                        }
                    }
                }
            }
        }
    };
    return connection.service.RetrieveMultiple(routingConditionQuery).Entities;
}