locked
Retrieve contact RRS feed

  • Question

  • Hi,

    I have retrieved the contactid of the crm contacts from sql data base. I have a view id too which describes which view is that like Active contacts or My active contacts.

    I want to check whether the retrieved contact belongs to a particular view or not.

    I want to share only the My active contacts. So i want to check whether the selected contact belongs to My active contact or not..

    How can i do this????

    Please any one help me..

     

    Monday, July 26, 2010 10:45 AM

Answers

  • I don't know how to explain more detailed but i will try:

    1. Using Retrieve method of crmservice you can get SavedQuery entity instance based on identifier of this entity.

    2. From this entity instance you can get FetchXML field.

    3. You should load FetchXML value into XMLDocument instance and add there filter by contact.

    4. Using Fetch method of crmservice and passing modified FetchXML (from step 3) you can check the count of records was returned. If it is equal 1 - this record is in the view. In other case - this record is out those view.

     

    That's all.


    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    Monday, July 26, 2010 11:18 AM
    Moderator

All replies

  • Hi.

    All views in field FetchXML has Fetch query used to get records. All you need - get those fetchxml, extend it with adding filter by contact id like:

    Active Contacts Fetch:

    <fetch version="1.0" output-format="xml-platform" mapping="logical">
    <entity name="contact">
    <attribute name="fullname" />
    <order attribute="fullname" descending="false" />
    <attribute name="parentcustomerid" />
    <filter type="and">
    <condition attribute="ownerid" operator="eq-userid" />
    <condition attribute="statecode" operator="eq" value="0" />
    </filter>
    <attribute name="telephone1" />
    <attribute name="emailaddress1" />
    <attribute name="contactid" />
    </entity>
    </fetch>
    
    extend it with filter by contact you want to check (like adding <condition attribute="contactid" operator="eq" value="identifier of contact to check" />)

    and executing retrieve Fetch request - if one record is returned - this contact is in a view you want to check. If 0 then it is out of those view.


    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    Monday, July 26, 2010 10:58 AM
    Moderator
  • Hi,

    I am working with the C# code.

    I am want to perform the action from my custom aspx page. So i want the concept in C#???

    Can you help please???

    Monday, July 26, 2010 11:04 AM
  • I don't know how to explain more detailed but i will try:

    1. Using Retrieve method of crmservice you can get SavedQuery entity instance based on identifier of this entity.

    2. From this entity instance you can get FetchXML field.

    3. You should load FetchXML value into XMLDocument instance and add there filter by contact.

    4. Using Fetch method of crmservice and passing modified FetchXML (from step 3) you can check the count of records was returned. If it is equal 1 - this record is in the view. In other case - this record is out those view.

     

    That's all.


    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    Monday, July 26, 2010 11:18 AM
    Moderator