String.split() in data directives

I am trying to use string.split() in a BPM custom code block the syntax is fine but I might be missing something. I am setting a variable equal to ttsysrptlst.systasknum in a argument/variable set widget. I have log messages and it shows a result like 123456;123456;123456. I am capturing a report after printing and it is using APR so it creates 3 records. but in ttSysRptLst it appears they are concatenated on one row. I need the Systasknum to be able to get other data. The below code works in other scenarios but this one i keep getting a null reference error. Anyone have any idea what I am missing or a better way to do this.

string s = CurSysTaskNum;

//s.Replace(';','~'); //***tried replacing with a different character 
string[] ss = s.Split(';');

if(ss != null && ss.Length > 0)
{
  FirstCurSysTaskNum = ss[0]; // set second variable equal to the first result in the array
}

Are you sure CurSysTaskNum is not Null or Empty?

You could try this:

string s = null;

if (!string.IsNullOrEmpty(s))
{
	//s.Replace(';','~'); //***tried replacing with a different character 
	string[] ss = s.Split(';');

	if(ss != null && ss.Length > 0)
	{
	  string a = ss[0]; // set second variable equal to the first result in the array
	}
}

I checked the logs and it is empty. I was mistaking the query field in the log for this one.
Why would the log query be able to access ttSysRptLst but not set argument/variable with this expression.

ttSysRptLstRow.SysTaskNum.ToString()

How can I access ttSysRptLst right from the code block. I was always told you shouldn’t access the tt tables from code but I know it’s possible.

Who told you that mess?

Are you sure your variable CurSysTaskNum isn’t null?

I think he is referring to joining ttTables to Db in a bpm.

That’s exactly what I was referring to. I also never had a need to use the temp tables. I just can’t figure out why the variable isn’t setting to the field.

Ok step back. What are you trying to do?
What data directive is this on. What type?

What I am trying to do is to run a report after an APR routing runs. I need two different reports at the same time. I have gotten everything working except the print report widget runs 3 times because APR puts three rows in the tt table. I am currently trying to use code to run the report but can’t pull the adapters into custom code widget in the data directive. Do you by chance know if this is possible. I am getting the missing assembly reference error but I have all the references to orderack.

Yep.

Show your code and details.

Sorry for being vague I have a few projects running at the same time and jumping around.

The code below compiles but throughs an error on the server. I finally figured out how to get it to load the adapter but it throws the run time error below the code. I really just need to access the order Ack adapter. I have done this in customizations and method directives but this is a data directive which runs on the server.

            soaa.BOConnect();

            soaa.GetNewParameters();
            soaa.ReportData.SalesOrderAckParam[0].OrderNum = CurOrderNum ;
            soaa.ReportData.SalesOrderAckParam[0].AgentID = "SystemTaskAgent";
            soaa.ReportData.SalesOrderAckParam[0].ReportStyleNum = 1006;  

            Guid workstationid = Guid.NewGuid();
            soaa.ReportData.SalesOrderAckParam[0].WorkstationID = String.Format("{0}", workstationid);
            soaa.ReportData.SalesOrderAckParam[0].ArchiveCode = 1;
            soaa.ReportData.SalesOrderAckParam[0].AutoAction = "Print"; //generate
            soaa.ReportData.SalesOrderAckParam[0].PrinterName = @"\\WI10ET2RPT1\IT_HP";
            soaa.SubmitToAgent("SystemTaskAgent", 0, 0);

The error is
Ice.Common.EpicorServerException: BPM runtime caught an unexpected exception of ‘FileNotFoundException’ type.
See more info in the Inner Exception section of Exception Details.

  • —> System.IO.FileNotFoundException: Could not load file or assembly ‘Erp.UIRpt.SalesOrderAck, Version=11.2.300.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’. The system cannot find the file specified.*
    File name: ‘Erp.UIRpt.SalesOrderAck, Version=11.2.300.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’

If this code is in a data directive, it’s not going to work.

Adapters are for client customizations.

I figured as much but I have to either use code or accept that the pint widget will send 3 of the report I want. Do you know of another way? I was thinking a method directive but assumed I would get the same issue.

You just have to use the correct code.

In BPMs you use the business objects directly. Let me take a look at it and see if I can get you started.