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.
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);
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)
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.
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.
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)
is working on a reply...