Answered

Validation of entered value in an existing table

Hello

As start of a returns process, I'd like the user to enter a Sales Order Number and Customer Number.

The expression manager should:

1) check if the entered value for the Sales Order exists in the table of Sales Orders

2) check if the entered value of Customer Number exists in the Customer master data

3) check if the combination of two values is valid

Is the expression manager the right tool for this? If so, is the function 'Exist' the right function? I do no quiet understand the syntax.

Kind regards

Comments (1)

photo
1

You may close this question. I hope this is useful for somebody who encounters the same situation.

I managed to realize, after much trial and error:

var order = <Returns1.OnlineReturn.SalesOrderNumberAsEntered>;

var customernr = <Returns1.OnlineReturn.CustomerNumberAsEntered>;

var customers = CEntityManager.GetEntity("Customer").GetEntityList("CustomerNumber", customernr, "", "");

if(customers.Length == 0)

{

CHelper.ThrowValidationError("Customer number is not known in our database");

}

else

{

var Customerid = customers[0].SurrogateKeyValue;

}

var FilterDocs = "Customer =" + Customerid + " and SalesOrderNumber= " + order;

var orders = CEntityManager.GetEntity("SalesOrder").GetEntityList("", "", FilterDocs, "");

if(orders.Length == 0)

{

CHelper.ThrowValidationError("Valid customer number, however salesorder number is not known");

}

else

{

<Returns1.SalesOrder> = orders[0].SurrogateKeyValue;

}