C# structs in BPM

,

Is it possible for me to use a struct in a BPM? I can’t seem to get it to work.

Can you post your code? not sure why it wouldn’t work…

@Aaron_Moreng

I opened the code block in a BPM and tried this and it doesn’t like it.

	struct myRow
	{
		string jobNum;
		string assemblySeq;
		string oprSeq;
	}

Since it’s being declared inside of a method (custom code block), we cannot allow defined types. You might be able to use something like this to accomplish what you’re after.

var myRow = new {jobNum = "", assemblySeq = "", oprSeq = ""};

You can’t declare a struct inside a method so no not typically.

That is too bad.

I ended up doing something like this:

var myRow = ttResults_iterator.LaborDtl_JobNum.ToString() + "-" + ttResults_iterator.LaborDtl_AssemblySeq.ToString() + "-" + ttResults_iterator.LaborDtl_OprSeq.ToString();
if (!myList.Contains(myRow)){
	myList.Add(myRow);
}

and then later this:

foreach (var st in myList) {
	var jobNum = st.Entry(0,"-").ToString();
	var assemblySeq = Convert.ToInt32(st.Entry(1,"-"));
	var oprSeq = Convert.ToInt32(st.Entry(2,"-"));

}

Hey Joe,

If you’re just doing a table, do you really need a struct? Can you use the built-in system.dataset instead? I believe @josecgomez had an example of building a dataset in a BPM in the forum somewhere.

Mark W.

1 Like

if it’s something you truly need to call over and over again look into c# Actions

1 Like