Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

create custom view with c# code

Posted on by 15

Hello,

Customer Service agents asked me to create a custom view (at advanced find) on contacts, that shows all contacts that:

- have a relating case (where the contact is in  Customer field of case)  with a certain subject (or title) (get the older case - initial case)

- have a number of relating cases (where the contact is in  Customer field of case) that created AFTER the initial case.

I never created custom views at advanced find with code, I find some codes in the internet, but I don't know how I can publish the code and show the new functionallity to the agents to use it.

Thank you in advance

Kassandra

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: create custom view with c# code

    If my reply helped you take a minute to verify an answer. In order to do that you can click "Yes" under the question "Did this answer your question?".

  • RE: create custom view with c# code

    So I must add a filter for ActivityParty.ParticipationTypeMask.Value --> 1 (sender <-- Email.From)

    Thank you very much!

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: create custom view with c# code

    You will have a need to d a filter for activityparty by participationtypemask field - docs.microsoft.com/.../activityparty-entity

  • RE: create custom view with c# code

    Hello Andrew,

    Thank you for your answer.

    Finally we found another solution.

    Now I struggle with code.

    I want to filter all the emails that are FROM a particular contact

    I found the code to find all the mails that are sent TO a particular contact

    QueryExpression qe = new QueryExpression

                       {

                           EntityName = "email",

                           Criteria = new FilterExpression

                           {

                               FilterOperator = LogicalOperator.And,

                               Conditions =

                           {                                                    

                               new ConditionExpression

                               {

                                   AttributeName = "createdon",

                                   Operator = ConditionOperator.GreaterThan,

                                   Values =

                                   {

                                       caseCreated

                                   }

                               }

                           }

                           },

                           LinkEntities =

                       {

                           new LinkEntity

                           {

                               LinkFromEntityName = "activitypointer",

                               LinkFromAttributeName = "activityid",

                               LinkToEntityName = "activityparty",

                               LinkToAttributeName = "activityid",

                               LinkCriteria = new FilterExpression

                               {

                                   FilterOperator = LogicalOperator.And,

                                   Conditions =

                                   {

                                       new ConditionExpression

                                       {

                                           AttributeName = "partyid",

                                           Operator = ConditionOperator.Equal,

                                           Values =

                                           {

                                               Contact.Id

                                           }

                                       }

                                   }

                               }

                           }

                       }

                       };

                       relatedEmails = service.RetrieveMultiple(qe).Entities.ToList();

    How I change the code to find emails that are FROM the contact? Or this code gets both TO and FROM?

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: create custom view with c# code

    Hello Kassandra,

    Why do you want to create this View using the code? What is the point?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans