Hello,
There is form called Delivery Challan where there is a subform in which there are 2 lookup fields Design No. and Shade No.
Now the problem i want to validate whether the particular design no or shade no exist in the stock or not and for that i believe count function is the only feasible option (if there is another do recommend).
Now i have tried the code but it seems to doesnot work with subform i guess.
Following is the code:
- if(Outward_Type == "Fabric")
- {
- for each rec_Fab in Fabric
- {
- Fab_Obj = Fabric_Stock_Master[Shade_No == rec_Fab.Shade_No];
- if(count(rec_Fab.Design_No) == 0) // This is the code to check whether it exists or not
- {
- alert "Does not exist";
- cancel submit;
- }
- else if(Fab_Obj.count() > 0)
- {
- for each rec_Fab_Obj in Fab_Obj
- {
- if(rec_Fab_Obj.Design_No == rec_Fab.Design_No)
- {
- if(rec_Fab.Quantity > rec_Fab_Obj.Meter)
- {
- alert "Test";
- cancel submit;
- }
- }
- }
- }
- }
- }
But when i update the code and leave the code changes.
- if(Outward_Type == "Fabric")
- {
- for each rec_Fab in Fabric
- {
- Fab_Obj = Fabric_Stock_Master[Shade_No == rec_Fab.Shade_No];
- if(rec_Fab.count() == 0) // This is the change in the code after i update and leave
- {
- alert "Does not exist";
- cancel submit;
- }
- else if(Fab_Obj.count() > 0)
- {
- for each rec_Fab_Obj in Fab_Obj
- {
- if(rec_Fab_Obj.Design_No == rec_Fab.Design_No)
- {
- if(rec_Fab.Quantity > rec_Fab_Obj.Meter)
- {
- alert "Test";
- cancel submit;
- }
- }
- }
- }
- }
- }