Can some one please help me with this code snippet?

I am running this code as a script task in a business process.

string POid = Get<string>("PurchaseOrderID");
var arParts = POid.Split('_');
		int i = Convert.ToInt32(arParts[1]);
		int newid = i + 1;
		string prefix = string.Empty;
		else if (newid<100)
		{ prefix="0000";
		else if (newid<1000)
		else if (newid<10000)
		else if (newid<100000)
		string intstringid = newid.ToString();
		string name = prefix + intstringid; 
		string newPOid = "PO_" + name;
		Set("NewPurchaseOrderID", newPOid);
return true;

I have "PurchaseOrderID" and "NewPurchaseOrderID" as the parameters that I've defined for this business process. They are spelled as in the code, I've checked that.


When I try to run this process, I get the error: Object reference not set to an instance of an object.


Can't seem to find which object I have not initiated.


Any help would be appreciated.




Like 0



It seems that  "PurchaseOrderID"  parameter has no value, so in the following row

var arParts = POid.Split('_')

the error "Object reference not set to an instance of an object" occurs because POid is null. To know for sure please debug the code. The article by the link below will be helpful in that:

Show all comments