locked
What is Listid ??? how do i get the listid ? From Microsoft Dynamics CRM 2013 RRS feed

  • Question

  •  Hi all how to Get My ListId From the marketing list in Microsoft Dynamics CRM 2013

    Wednesday, December 10, 2014 11:10 AM

All replies

  • What is Listid ??? how do i get the listid ? From Microsoft Dynamics CRM 2013

    ListId is the Uniqueidentifier/PrimaryKey field of MarketingList entity.
    You can get that field value in Client Side by below statement:
    Xrm.Page.data.entity.getId()
    It returns a string representing the GUID id value for the record. (something like: "{825CB223-A651-DF11-AA8B-00155DBA3804}")

    Code is different for Server side. Where you want to get the ListId? In which Scenario?
    • Proposed as answer by Piyush Parate Wednesday, December 10, 2014 11:51 AM
    • Unproposed as answer by Piyush Parate Wednesday, December 10, 2014 11:51 AM
    • Edited by Piyush Parate Wednesday, December 10, 2014 12:12 PM
    Wednesday, December 10, 2014 11:39 AM
  • Hi,

    If you open the list in a new window (right click, new window) you will see the id in the url field of the browser. It's a bit tricky to spot if you're unused to it but the url shown will be something like http://<lots of stuff here>&id=%7b<GUID>%7d<more stuff> so the list id is the characters between %7b and %7d in the url field.

    Hope this helps


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Wednesday, December 10, 2014 3:04 PM
  • I want add Members in  CustomEntity so i need the ListId 

    am using This Code 

    AddMemberListRequest req = new AddMemberListRequest();
    //we will add an account to our customEntity 
    //entity type must be an account, contact, or lead
    req.EntityId = new Guid("CCB265C9-5F0C-E111-BF0B-1CC1DEE89AA8");
    //we will add the account to this existing marketing list
    req.ListId = new Guid("6CAC04FC-930F-E111-8DB2-1CC1DEF1B5FF");
    AddMemberListResponse resp = (AddMemberListResponse)slos.Execute(req);

    Thursday, December 11, 2014 6:30 AM
  • Did you create the List? (the list which you reffer - 6CAC04FC-930F-E111-8DB2-1CC1DEF1B5FF)
    req.ListId = new Guid("6CAC04FC-930F-E111-8DB2-1CC1DEF1B5FF");

    If you didnt create that List create it like below:

    list autoList = new list();
    autoList.listname = "Test List"; autoList.membertype = new CrmNumber(); autoList.membertype.Value = 1; autoList.createdfromcode = new Picklist(); autoList.createdfromcode.Value = 1; Guid listId = service.Create(autoList);

    And use this "listId" insteed of yours new Guid("6CAC04FC-930F-E111-8DB2-1CC1DEF1B5FF");

    Reffer: http://msdn.microsoft.com/en-us/library/cc151192.aspx

    Thursday, December 11, 2014 7:07 AM
  • Hi,

    There are a few ways you can do this. Either you have to create the list, and then you follow ChangeFrenzold's intruction, or you already have the marketing list in the system and then you could follow the instruction I made earlier to get the ID and then hard code it into the code pretty much like you've done already but with the GUID you need to use.

    If you want to fin the list id in the code you need to get the marketing list you want to use with something like the following:

    QueryByAttribute qba = new QueryByAttribute("list");
    qba.ColumnSet = new ColumnSet();
    qba.ColumnSet.AddColumn("name");
    qba.Attributes.Add("name");
    qba.Values.Add("listname");
    Entity thisList = ((EntityCollection)service.RetrieveMultiple(qba))[0];
                        

    This will give you the list with name "listname" and in your request the req.ListId will be thislist.Id

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Thursday, December 11, 2014 8:04 AM
  • Hi ChangeFrenzoId Presently Am using CRM 2013
    Thursday, December 11, 2014 12:13 PM
  • Hi ChangeFrenzoId 

    When Ever I Adding

    Error1:-The type or namespace name 'CrmNumber' could not be found (are you missing a using directive or an assembly reference?)

    autoList.membertype = new CrmNumber();

    Error2:- Property or indexer 'System.Nullable<int>.Value' cannot be assigned to -- it is read only autoList.membertype.Value = 1;

    This Is My Code

    List autolist = new List();

               autolist.ListName = "CallingList";

               autolist.MemberType = new Int32();

               autolist.MemberType.Value = 1008;

               autolist.CreatedFromCode = new OptionSetValue();

               autolist.CreatedFromCode.Value = 4; // Lead EntityType Code

               Guid listId = _serviceProxy.Create(autolist);

               AddListMembersListRequest addRequest = new AddListMembersListRequest();

               AddMemberListResponse response = (AddMemberListResponse)_serviceProxy.Execute(addRequest);

    Please provide Some Suggestions 

    thank u

    Monday, December 15, 2014 12:33 PM
  • Hi,

    What happens if you just try "autolist.MemberType = 1008;"? That field is an int.

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Monday, December 15, 2014 12:41 PM