I have a table, which i am creating a method on, i want run on action based on duplicatie values from 2 fields.
For example:
I have Table A
which contains these fields:
IncidentDescription
Identifier
Now i want to run a certain action in the method based on the following criteria:
If the IncidentDescription
already exists in another row in the same table, but only if the Identifier
is different. (So it doesn't run the action if only 1 line with the IncidentDescription exists)
How can i solve this? Is it possible to accomplish this in an if statement
?
Or is there a possibility/is it better to run a "while select" query, and (if it exists) run a count method based on the count result (>1).
EDIT:
I am trying to create the query as following:
select count (IncidentDescription) from TableA;
{
// I am trying to convert the result, because it gives me the error: "Operand types are not compatible with the operator, i am not sure how to make this.
serialCount = str2num(IncidentDescription);
if (IncidentDescription > 1)
//Action to go here;
}
I will build in the Identifier later.
Please use the following code as a hint and modify it according to your requirements:
TableA tableA;
TableA tableAJoin;
;
select firstOnly tableA
join tableAJoin
where tableA.IncidentDescription == tableAJoin.IncidentDescription
&& tableA.Identifier != tableAJoin.Identifier;
if (tableA.RecId)
{
info(strFmt("%1 - %2", tableA.Identifier, tableA.IncidentDescription));
info(strFmt("%1 - %2", tableAJoin.Identifier, tableAJoin.IncidentDescription));
}
If you need this check for displayOption
method on a form datasource (where tableA is a datasource name), then modify it as follows
public void displayOption(Common _record, FormRowDisplayOption _options)
{
TableA tableACurrent;
TableA tableALocal;
;
tableACurrent = _record;
select firstOnly RecId from tableALocal
where tableALocal.IncidentDescription == tableACurrent.IncidentDescription
&& tableALocal.Identifier != tableACurrent.Identifier;
if (tableALocal.Identifier)
{
//record has dublicates
...
}
super(_record, _options);
}