I added a checkbox field in projTable where i limit turning it into a yes based on a condition in recursive function. So i created a new recursive method that i call inside the validateField method. If my recursive method returns true no validation occurs but if it returns false an error message should appear. What my recursive method is doing, is that it makes the return value false but it then calls itself again and make the return value true always. what should i do? Here's what i did:
[ExtensionOf(tableStr(ProjTable))]
final class ProjTable_Extension
{
/// <summary>
///
/// </summary>
/// <returns></returns>
///
public boolean validateField(FieldId fieldId)
{
boolean ret;
boolean retCheck = true;
ret = next validateField(fieldId);
switch (fieldId)
{
case fieldNum(ProjTable, TestField) :
retCheck = this.getProj(this.ProjId); // this is the method i created
if (!retCheck)
{
ret = ret && checkFailed("Error");
}
break;
}
return ret;
}
boolean getProj(ProjId _projId = "")
{
boolean ret = true; // initial value
ProjTable projTable;
while select projTable
where projTable.parentId == _projId
{
if(projTable.TestField== NoYes::Yes)
{
ret = false;
return ret ; // it comes inside and put ret = false then it gets out of the while loop, then go back to the else, then go to the final ret and return it true always
}
else
{
this.getProj(this.projId); //after setting ret = false it still comes here and then return ret = true
}
}
return ret ; //always returns true
}
what am I doing wrong? If my code in the new method makes ret false, why does it return true value to retCheck?