Hello everyone! I need help accessing data from the rows of a table in my element, in order to validate whether a record already exists. I tried using methos like GetParameter, but without success(keep getting "-1" as return, even if the information in the table is correct).
With the code bellow i can access the "primaryKey" column because it is a DisplayKey in my table and validate it, but JobID is not a key item, but need to be unique. How can i do it?
Element element = engine.FindElement("MP API Interface");
var requestBody = JsonConvert.DeserializeObject<JobData>(requestData.RawBody);
string primaryKey = $"{requestBody.WorkOrderId}/{requestBody.ServiceDefinitionName}/{requestBody.ServiceDefinitionGroup}";
string jobID = "";
do{
jobID = Guid.NewGuid().ToString();
string [] primaryKeys = element.GetTableDisplayKeys(7000);
if(primaryKeys.Contains(primaryKey)){
{engine.GenerateInformation("Registry found");}
else
{engine.GenerateInformation("New Registry");}
} while()
P.S.:The column "Instance ID" which is generated by DataMiner is the PK in my table.
P.S. 2: The while condition will be defined after i have a way to validate the info.
P.S. 3: As asked, i'm leaving the Table image. We will change the table Primary Key to the column "Primary Key"(ID 7020) and the Display Key to the column "Job ID"(ID 7001).
Thank you all in advance for your attention!
Hello Jorge, sorry the delay and thank you for your response. I updated the question with the asked information.
Hi João, column Primary Key seems to have repeated value which should not be the case, each value should be unique maybe that is the reason.
Could you also debug the content of primaryKeys variable? By doing a foreach and generating an information event with the content for instance to see what you get?
It has duplicated values because we can't access the table column values to validate it, this is the point of this question. The variable primaryKey in my code is a string built with some info that come from the request body. As i reported initaly, i can access the data in a column with a tag "Display Key", but i can't access the column "Primary Key" tag.
Yes, I needed to know the content of the primaryKeys array that is fetched from GetTableDisplayKeys. Normally the code should work, needed that to know if the issue comes from that method not returning what we are expecting
It looks like this question has already been answered in the comments. To make it clear that this question no longer requires an answer, I have added this pro forma answer so that we can mark it as resolved.
Hi João, to help understand the logic that needs to be implemented could you add a screenshot of your table with the primaryKey/displayKey, the ID(s) of those columns and the value that is composed in your primary key variable from your code?