Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Damion 96 posts 331 karma points
    Mar 23, 2020 @ 09:56
    Damion
    0

    Importing Members and linking to related content

    I have an import function in my v8 app where users can import members.

    The members have several extended properties, including the organisation they belong to, the organisations are documents themselves and contain all info on that organisation.

    Adding a member in the back office, the organisation is selected when the user clicks the 'Add' button. enter image description here

    Each member contains the organisation name which I can run an Examine query and find the organisation document (and therefore it's Id), how can I add (or link) it to the member during an inport?

    Here is the code so far showing the Examine query and the line where I would set the imported member organisation. On checking, the member is added, but nothing appears where organisation should be added.

    var searcher = index.GetSearcher();
                    var results = searcher.CreateQuery("content").NodeTypeAlias("organisation").And().Field("clientName", member.OrganisationName).Execute();
                    var _id = "";
                    foreach (var result in results)
                    {
                        _id = result.Id;
                    }
                    customMember.SetValue("organisation", _id);
    
  • Tom Madden 252 posts 454 karma points MVP 4x c-trib
    Mar 23, 2020 @ 13:32
    Tom Madden
    0

    Hi Damion,

    I think you need to serialize the value to json before you set it. You can combine this into a single statement, but this will let you see it step by step

    var value = JsonConvert.SerializeObject(_id); customMember.SetValue("organisation", value)

Please Sign in or register to post replies

Write your reply to:

Draft