Answered
Compare one cell of a row with another rows
Hi everybody. My question is:
I have a table of items that will be requested for purchase process. each item have several components like name, code, stock, warehouse and etc. i want to set a validation for table that check the warehouse of any items(rows) with warehouse of first row and if it's not equal do not add this row and display a error massage.
Dear Alireza
In Bizagi, you can define an Expression (Activity Action) on the Exit of an activity.
The expression can be a script as below, where in you can replace the "ProcessEntity" with the name of your ProcessEntity, "TableOfItems" with the name of your collection in the ProcessEntity and "Warehouse" with the name of the attribute you want to compare.
var size = <count(ProcessEntity.TableOfItems)>;
var firstRowWarehouse = "";
for (var i=1; i<=size; i++)
{
var currItem = Me.getXPath("ProcessEntity.TableOfItems["+ i +"]");
if(i== 1){
firstRowWarehouse = currItem.getXPath("Warehouse");
}else{
if(firstRowWarehouse != currItem.getXPath("Warehouse")){
CHelper.ThrowValidationError("Warehouse of all rows must be same");
}
}
}
Hope this helps!
Best Regards
Dear Alireza
In Bizagi, you can define an Expression (Activity Action) on the Exit of an activity.
The expression can be a script as below, where in you can replace the "ProcessEntity" with the name of your ProcessEntity, "TableOfItems" with the name of your collection in the ProcessEntity and "Warehouse" with the name of the attribute you want to compare.
var size = <count(ProcessEntity.TableOfItems)>;
var firstRowWarehouse = "";
for (var i=1; i<=size; i++)
{
var currItem = Me.getXPath("ProcessEntity.TableOfItems["+ i +"]");
if(i== 1){
firstRowWarehouse = currItem.getXPath("Warehouse");
}else{
if(firstRowWarehouse != currItem.getXPath("Warehouse")){
CHelper.ThrowValidationError("Warehouse of all rows must be same");
}
}
}
Hope this helps!
Best Regards
Comments have been locked on this page!