function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
paulie69paulie69 

Problem in Serach C# example

Just to let you know -

I search for xxx which does not exist.

The following code gets a true returned

if(sForce.SampleSearch(accountName,out accountID))

{

if(accountID.Length > 1)

{

int i;

Console.WriteLine("Found multiple matching accounts (" + accountID.Length + ")...");

for(i=accountID.GetLowerBound(0);i<=accountID.GetUpperBound(0);i++)

{

Console.WriteLine("\t" + (i + 1) + ": account " + accountID[i] + " using " + accountName + " as the search value.");

}

}

else

{

Console.WriteLine("Found the account " + accountID[0] + " using " + accountName + " as the search value.");

}

}

else

{

Console.WriteLine("Could not find an account using " + accountName);

}

 

What happens is the accountId array length is zero but the test is greater than 1 so the fall through tries to access item 0 of an array that has no item.

Regards,

Paul

 

DevAngelDevAngel

Good point Paulie.  It should be testing to see if the length is > 0.  We will provide updated samples shortly.

Dave