web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Validation on Form level for multiple expenses on total sum of amount

(0) ShareShare
ReportReport
Posted on by 212

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

pastedimage1639077209845v1.png

[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");
}
}
}

I have the same question (0)
  • GirishS Profile Picture
    27,827 Moderator on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans