locked
Web Service API issue when trying to create Consolidated Member RRS feed

  • Question

  • Hi All, I am trying to create a consolidated member using web services and the call goes fine without any error but the member that is created is a leaf member.

    Here is the code:

    using (ServiceClient c = this.CreateMDSProxy())
          {
            Member newMember = new Member();
            newMember.MemberId = new MemberIdentifier() { Code = memberCode, Name = memberName };
            
            EntityMembers members = new EntityMembers();
            members.ModelId = new Identifier { Name = modelName };
            members.EntityId = new Identifier { Name = entityName };
            members.VersionId = new Identifier { Name = versionName };
            members.MemberType = MemberType.Consolidated; // --- this doesn't make a difference, member is still added as a leaf
            
            // Add childMember to "members" via .Members property
            members.Members = new Collection<Member> { newMember };
            
    
            OperationResult or = c.EntityMembersCreate(new International(), members);
            if (or.Errors.Count > 0)
    I have verified that the member gets created with code, name, model, version etc. correctly. Except it adds as a leaf instead as a consolidated member.

    I am hoping Xavier [xavave] and/or other experts have a solution or suggestions.

    Thanks.


    Monday, May 9, 2011 11:14 AM

Answers

  • Ok, the trick was in setting up the parent property of newMember.Id which has the relationshiptype as well as the hierarchy:

        Member newMember = new Member();
        newMember.MemberId = new MemberIdentifier() { Code = memberCode, Name = memberName };
        newMember.MemberId.MemberType = MemberType.Consolidated;
    
        // Set the parents - which sets the hierarchy etc.
        Parent parent = new Parent();
        parent.HierarchyId = new Identifier() { Name = hiearchyName };
        parent.ParentId = new MemberIdentifier() { Code = parentCode };
        newMember.Parents = new Collection<Parent> { parent };
    
        // Create the collection and add
        EntityMembers members = new EntityMembers();
        members.ModelId = new Identifier { Name = modelName };
        members.EntityId = new Identifier { Name = entityName };
        members.VersionId = new Identifier { Name = versionName };
    

     

    Section in the middle "// Set the parents" is the key along with

    newMember.MemberId.MemberType = MemberType.Consolidated;<br/>
    
    It is all working now. Again, MDS team, please document this API. Publishing system generated documentation is not really helping those who are not closely attached to the dev team. New book on MDS also does not cover some basic/crucial parts of the API like this post.

    • Marked as answer by peersync Monday, May 9, 2011 12:04 PM
    Monday, May 9, 2011 12:04 PM

All replies

  • Hi,

    Have you enabled Explicit Hierarchies and Collections on the entity that you're trying to add to?

    HTH

    Jeremy


    http://blogs.adatis.co.uk/blogs/jeremykashel/default.aspx
    Monday, May 9, 2011 11:40 AM
  • Hi Jeremy, Thanks for your quick reply. Not collections, but explicit Hierarchy, yes. Actually, while debugging, I noticed that the member type is also a property on the member ID. So I tried that but now I am getting an error ""A valid hierarchy is required to create a consolidated member."" So there is hope. Now I am going to set the hierarchy - which means I need to set the parent also. Which is fine and I am trying that now. It is so disappointing that none of the web service API is documented well - WS API is an excellent tool for teams trying to extend the functionality of MDS. Anyway, back to trying all permutations and combinations. Thanks.
    Monday, May 9, 2011 11:49 AM
  • Sounds like you're on the right track.

    To create a consolidated member you need to follow these guidelines:

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

    Basically that means you can only add a consolidated member to an entity that has "Yes" selected to the option "Enable explicit hierarchies and collections". In addition you do need to pick a member as the parent in 1 explicit hierarchy (although this can be the Root). Note that consolidated members can only belong to 1 explicit hierarchy.

    So the above will apply whether you are creating a consolidated member in the front end or in the API


    http://blogs.adatis.co.uk/blogs/jeremykashel/default.aspx
    Monday, May 9, 2011 12:02 PM
  • Ok, the trick was in setting up the parent property of newMember.Id which has the relationshiptype as well as the hierarchy:

        Member newMember = new Member();
        newMember.MemberId = new MemberIdentifier() { Code = memberCode, Name = memberName };
        newMember.MemberId.MemberType = MemberType.Consolidated;
    
        // Set the parents - which sets the hierarchy etc.
        Parent parent = new Parent();
        parent.HierarchyId = new Identifier() { Name = hiearchyName };
        parent.ParentId = new MemberIdentifier() { Code = parentCode };
        newMember.Parents = new Collection<Parent> { parent };
    
        // Create the collection and add
        EntityMembers members = new EntityMembers();
        members.ModelId = new Identifier { Name = modelName };
        members.EntityId = new Identifier { Name = entityName };
        members.VersionId = new Identifier { Name = versionName };
    

     

    Section in the middle "// Set the parents" is the key along with

    newMember.MemberId.MemberType = MemberType.Consolidated;<br/>
    
    It is all working now. Again, MDS team, please document this API. Publishing system generated documentation is not really helping those who are not closely attached to the dev team. New book on MDS also does not cover some basic/crucial parts of the API like this post.

    • Marked as answer by peersync Monday, May 9, 2011 12:04 PM
    Monday, May 9, 2011 12:04 PM