Hi team,
Please help me in this solution.
I have a expense category as OPD expenses and i wanted to put validation on form if expense amount is more than 5000 INR. I can add multiple expenses in 1 expense report so I have used on validating method but it not calculating the sum. Please help
[FormControlEventHandler(formControlStr(TrvExpenses, TrvExpTrans_AmountMST), FormControlEventType::Validating)]
public static void TrvExpTrans_AmountMST_OnValidating(FormControl sender, FormControlEventArgs e)
{
FormRun formRun = sender.formRun();
FormDataSource formDataSource = formRun.dataSource(formDataSourceStr(TrvExpenses,TrvExpTrans ));
TrvExpTrans TrvExpTrans = formDataSource.cursor();
real totalamt;
if(fieldNum(TrvExpTrans, AmountCurr))
{
select sum(AmountCurr) from trvExpTrans where
trvExpTrans.CostType == 'OPD Expenses'
&& trvexptrans.CreatedBy == curUserId() ;
totalamt = trvexptrans.AmountCurr;
if( totalamt >5000 && trvExpTrans.CostType == 'OPD Expenses' && trvexptrans.CreatedBy == curUserId())
{
throw Error ("OPD Expense cannot be claimed more than 5000 in a year");
}
}
}
Hi,
Have you debugged the code and find out whether if condition(checking the field num) returns true.
I don't think this one doesn't work for your scenario.
Try to use the COC command on table level validate method.
Thanks,
Girish S.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156