Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Appointment RetriveMuliple Plugin, Views and Charts (Related chart error)

  • 1.  Appointment RetriveMuliple Plugin, Views and Charts (Related chart error)

    GOLD CONTRIBUTOR
    Posted 24 days ago

    Hello everyone, 

    I developed a plugin on Appointment RetrieveMuliple and it is working great with Views and list, But it is not working with Dashboard & charts.

    Do you have any idea why ? 



    ------------------------------
    giovanni manunta
    Application Owner MS Dynamics 365 CE
    ------------------------------
    Academy - Online Interactive Learning from Experts


  • 2.  RE: Appointment RetriveMuliple Plugin, Views and Charts (Related chart error)

    TOP CONTRIBUTOR
    Posted 24 days ago
    Giovanni,
    CE uses different approach when data is retrieved for Charts/Dashboards so you would not be able to "override" the way how it retrieves it. What's your scenario and why do you need it - there is a chance that there is an alternative way to accomplish your goal.

    ------------------------------
    Andrew Butenko
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 3.  RE: Appointment RetriveMuliple Plugin, Views and Charts (Related chart error)

    GOLD CONTRIBUTOR
    Posted 24 days ago
    Edited by giovanni manunta 24 days ago
    Hello Andrew

    below this is the reason why I am using the Plugin on retrieve multiple.

    if I can override it in another way let me know

    I know that it is not the best code I can develop

    this plugin tries to check if the ower is the current user or one of the direct reports or a participant is a current user or one of these direct reports

    private static void EnrichQueryByHierarchyManagerininPatecipant(ITracingService log, IOrganizationService organizationService, QueryExpression query, EntityCollection users)
    {
    if (query == null) return;
    int position = -1;
    for (int i = 0; i < query.Criteria.Conditions.Count; i++)
    {
    var cond = query.Criteria.Conditions[i];
    if (cond.AttributeName == "my_usermanagerasowerandparticipant") { position = i; break; }
    }
    if(position != -1 ) query.Criteria.Conditions.RemoveAt(position) ;
    // Define Condition Values
    var QEappointment_0_0_activityparty_participationtypemask_1 = 7;
    var QEappointment_0_0_activityparty_participationtypemask_2 = 9;
    var QEappointment_0_0_activityparty_participationtypemask_3 = 5;
    var QEappointment_0_0_activityparty_participationtypemask_4 = 6;
    // Define filter QEappointment.Criteria
    var QEappointment_Criteria_0 = new FilterExpression();
    // Define filter QEappointment_Criteria_0
    QEappointment_Criteria_0.FilterOperator = LogicalOperator.Or;
    QEappointment_Criteria_0.AddCondition("systemuser", "systemuserid", ConditionOperator.EqualUserId);
    QEappointment_Criteria_0.AddCondition("systemuser", "my_user_hierarchyid", ConditionOperator.EqualUserId);
    //QEappointment_Criteria_0.AddCondition("systemuser", "my_user_hierarchyid", ConditionOperator.Equal, manager.Id);
    var QEappointment_Criteria_0_0 = new FilterExpression();
    QEappointment_Criteria_0.AddFilter(QEappointment_Criteria_0_0);
    // Define filter QEappointment_Criteria_0_0
    QEappointment_Criteria_0_0.AddCondition("activityparty", "participationtypemask", ConditionOperator.In, QEappointment_0_0_activityparty_participationtypemask_1, QEappointment_0_0_activityparty_participationtypemask_2, QEappointment_0_0_activityparty_participationtypemask_3, QEappointment_0_0_activityparty_participationtypemask_4);
    var QEappointment_Criteria_0_0_0 = new FilterExpression();
    QEappointment_Criteria_0_0.AddFilter(QEappointment_Criteria_0_0_0);
    QEappointment_Criteria_0_0_0.FilterOperator = LogicalOperator.Or;
    QEappointment_Criteria_0_0_0.AddCondition("activityparty", "partyid", ConditionOperator.EqualUserId);
    if(users.Entities.Count > 0)
    {
    var usersid = users.Entities.Select(x => x.ToEntityReference().Id).ToArray();
    for(int i=0;i< usersid.Length;i++)
    QEappointment_Criteria_0_0_0.AddCondition("activityparty", "partyid", ConditionOperator.In, usersid[i]);
    }
    // Add link-entity QEappointment_systemuser
    var QEappointment_systemuser = query.AddLink("systemuser", "owninguser", "systemuserid");
    QEappointment_systemuser.EntityAlias = "systemuser";
    // Add link-entity QEappointment_activityparty
    var QEappointment_activityparty = query.AddLink("activityparty", "activityid", "activityid");
    QEappointment_activityparty.EntityAlias = "activityparty";
    query.Criteria.Filters.Add(QEappointment_Criteria_0);

    ------------------------------
    giovanni manunta
    Application Owner MS Dynamics 365 CE
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 4.  RE: Appointment RetriveMuliple Plugin, Views and Charts (Related chart error)

    TOP CONTRIBUTOR
    Posted 24 days ago
    It's a bit hard to read all the queries and see the end result behind but my recommendation - try to build proper view using OOB views and use it within the query or create and pre-populate additional field that you will be able to use in the view to filter and represent the data in the proper way.

    ------------------------------
    Andrew Butenko
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 5.  RE: Appointment RetriveMuliple Plugin, Views and Charts (Related chart error)

    GOLD CONTRIBUTOR
    Posted 24 days ago
    Hello Andrew,

    I am not able to translate in fetch XML this code expression because dynamically I created the list of participants of the appointment,

    I try to figure out a custom business hierarchy filter condition (only of two-level mother-children hierarchy) I don't know if adding & filling a custom field help me in this context but I agree with you generally speaking, should be helpful.

    ------------------------------
    giovanni manunta
    Application Owner MS Dynamics 365 CE
    ------------------------------

    Academy - Online Interactive Learning from Experts


If you've found this thread useful, dive deeper into User Group community content by role