Check if the ServerItem exist or not before opening it to avoid the exception

  • 17 June 2015
  • 1 reply
  • 2 views

Userlevel 3
Badge +9

Hi,

 

I have code below to open the serveritem and to finish/kill it.

Using the foreach loop to get the "outsideChangeSerialNo" to finish the server item. Some of them have already finished.

Is there any way to check if the sever item already finished or exist, to avoid the exception "25225 Server Item Not Found with Serial" at below fist line.

 

/* How to check if server item exist? */

SourceCode.Workflow.Client.ServerItem serverItem = clientConnectionWF.OpenServerItem(outsideChangeSerialNo);
if (serverItem != null)
{
serverItem.Finish();
}


1 reply

Userlevel 3
Badge +9

I guess if there is no way to check the status of the server item.. below is the way to handle the exception and go on in loop..

 

foreach(Person a in people)
{
try
{
//fihish server item
}
catch
{
// do something if you want to.
}
} 

 

Reply