Adding Unique Values to a Variable from List with multiple Duplicates

Hello Epicor Community,
I have a Grid on a Dashboard where I can select multiple rows with a checkbox and with a button copy data to the clipboard. There is a report where I need to paste this data but it requires that I only use unique values.

My Grid looks like this. I’m copying OrderNum from selected rows. My selection includes rows that have the same OrderNum

My Goal is to copy all those OrderNums into a variable separated by tilde ~, but only copy unique values. Using my previous example like this:


I know how to add all values to the variable. Where I need help is how to code the logic to analyze the OrderNum; If it’s not in the variable then add it, if it is then go to next OrderNum.


Hi Luis!
You could try using a string compare.

Something like this crappy pseudo-code (not correct syntax):

int x = Compare (NewOrderID, UniqueOrderIDs);
if IsNumber(x) { 
//then your new order ID is in the unique list, so don't add it again.
else {
//your new order id is not in unique list, so add it.

Thank you, your reply took me closer to the answer. Here is how I did it.

string strOrderNum = "";
string strPartNum = "";
string UniqueOrderNum = "";
string UniquePartNum = "";

strOrderNum = r.Cells["OrderRel_OrderNum"].Text.ToString();
strPartNum  = r.Cells["OrderRel_PartNum"].Text.ToString();

int index1 = UniqueOrderNum.IndexOf(strOrderNum);
int index2 = UniquePartNum.IndexOf(strPartNum);

if (index1 < 0)
UniqueOrderNum += r.Cells["OrderRel_OrderNum"].Text.ToString() + "~";

if (index2 < 0)
UniquePartNum  += r.Cells["OrderRel_PartNum"].Text.ToString()+ "~";