hi All,
I am trying to create a separate federation in which I have a json file and I want to process the data and show to the search dialog box(logic is already implemented), method is executing but not showing any error but my data is not showing on UI
json FILE DATA:
{
"names": [
{
"name": "John"
},
{
"name": "Emily"
},
{
"name": "Michael"
}
]
}
Method:
//if (System.Diagnostics.Debugger.Launch()) System.Diagnostics.Debugger.Break(); // Debugging point
var innovator = this.getInnovator();
Item variablePath = this.newItem("Variable", "get");
variablePath.setProperty("name", "json_path");
Item pathItem = variablePath.apply();
string path = pathItem.getProperty("value", "");
if (path == "")
{
return this.getInnovator().newError("Path to the JSON file needs to be defined on the Variable item with name 'json_path'");
}
string jsonContent = File.ReadAllText(path);
var data = Newtonsoft.Json.Linq.JObject.Parse(jsonContent);
// Create a dictionary to store names
var nameDictionary = new Dictionary<string, string>();
// Check for the existence of 'names' and populate the dictionary with 'name' values
if (data["names"] != null)
{
foreach (var nameObject in data["names"])
{
if (nameObject["name"] != null)
{
string nameValue = (string)nameObject["name"];
string id = this.getInnovator().getNewID(); // Generate a unique ID
nameDictionary[id] = nameValue;
}
}
}
// Create a container item to hold 'qs_call_clover' items
Item res5 = this.newItem();
res5.setType("qs_call");
// Loop to create and add items to the container in Aras Innovator based on the dictionary entries
foreach (var entry in nameDictionary)
{
//string id = entry.Key;
string nameValue = entry.Value;
Item currItm = this.newItem("qs_call");
string newid = getNewID();
// currItm.setID(newid);
currItm = currItm.apply();
currItm.setProperty("_name", nameValue);
res5.appendItem(currItm); // Add the item to the container
}
// Return the container item holding 'qs_call_clover' items
return res5;
please help...