locked
get member of marketing list RRS feed

  • Question

  •  

    how do i retrieve the members of a marketing list?
    Wednesday, November 26, 2008 9:11 PM

Answers

  • * CRMType = helper class to retrieve CRM service object
    * VListmember is custom class to store a listmember, you may want to retrieve 'entitytype' to determine whether a
    contact/account/lead.

    public Vlistmember[] Retrievelistmembers(string listid)
    {
            string strQuery;
        
            try
            {
            strQuery = "<fetch mapping='logical'>";
            strQuery += "<entity name='listmember'>";
            strQuery += "<attribute name='listmemberid'/>";
            strQuery += "<filter type='and'>";
            strQuery += "<condition attribute='listid' operator='eq' value='"+ listid + "'/>";      
            strQuery += "</filter>";
            strQuery += "</entity></fetch>";
            string strOutput = CrmTypes.CRMServ.Fetch(strQuery);
            XmlDocument xd = new XmlDocument();
            xd.LoadXml(strOutput);
            XmlNodeList xnl =  xd.SelectNodes("//listmemberid");
            if (xnl.Count > 0)
            {
                Vlistmember[] t = new Vlistmember[xnl.Count];
                int x = 0;
                foreach(XmlNode xn in xnl)
                {
                    Guid dispGuid = new Guid(xn.InnerText);
                    t[x] =  new Vlistmember(dispGuid);
                    x++;
                }
                return t;
            }
            else
            return null;
            }
            catch (System.Web.Services.Protocols.SoapException)
            {
                throw;
            }
    }

    Cheers,

    Karlo
    Wednesday, November 26, 2008 10:01 PM

All replies

  • * CRMType = helper class to retrieve CRM service object
    * VListmember is custom class to store a listmember, you may want to retrieve 'entitytype' to determine whether a
    contact/account/lead.

    public Vlistmember[] Retrievelistmembers(string listid)
    {
            string strQuery;
        
            try
            {
            strQuery = "<fetch mapping='logical'>";
            strQuery += "<entity name='listmember'>";
            strQuery += "<attribute name='listmemberid'/>";
            strQuery += "<filter type='and'>";
            strQuery += "<condition attribute='listid' operator='eq' value='"+ listid + "'/>";      
            strQuery += "</filter>";
            strQuery += "</entity></fetch>";
            string strOutput = CrmTypes.CRMServ.Fetch(strQuery);
            XmlDocument xd = new XmlDocument();
            xd.LoadXml(strOutput);
            XmlNodeList xnl =  xd.SelectNodes("//listmemberid");
            if (xnl.Count > 0)
            {
                Vlistmember[] t = new Vlistmember[xnl.Count];
                int x = 0;
                foreach(XmlNode xn in xnl)
                {
                    Guid dispGuid = new Guid(xn.InnerText);
                    t[x] =  new Vlistmember(dispGuid);
                    x++;
                }
                return t;
            }
            else
            return null;
            }
            catch (System.Web.Services.Protocols.SoapException)
            {
                throw;
            }
    }

    Cheers,

    Karlo
    Wednesday, November 26, 2008 10:01 PM
  • i get invlaid platform argument

     

    it doesnt like    strQuery += "<entity name='listmember'>";

     

    Monday, December 1, 2008 3:58 PM
  • Hi T,

    I've successfully tested on both 3.0 and 4.0.

    Could you elaborate on the error message (btw code is in C#) ?

    Thanks,

    Karlo
    Monday, December 1, 2008 5:03 PM
  • i misspelled something -- thanks

     

    Monday, December 1, 2008 6:13 PM