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, ...
Suggested Answer

Form Validation

(0) ShareShare
ReportReport
Posted on by

I just want a simple validation code....

1641.png

this is my form A named -> ProjInvoiceTable

In this billing rules lines it is showing contract value field , on this field i have to put validation.. (Contract Value Field is coming from PsaContractLineItems-> LineValue)

036341.png

It is also showing the field Contract value with the sum of all lines of Milestones ..

8623.png

It is the form ProjFundingSourceDetail and the PO lines is my Customized Tab..

now the thing I want is the sum of this BaseAmount(Coming from table FXProjFundingPOLines) field in POLines Tab must not be greater than the LineValue field of PsaContractLineItems ..

In both tables i.e PsaContractLineItems and FXProjFundingPOLines, common reference is ContractId....

this validation i had to put ...

I have the same question (0)
  • Sukrut Parab Profile Picture
    71,710 Moderator on at

    What challenges you are facing ? You know the relationship then its just the matter of pulling value and doing comparison ? Write it in  the modified field event of the table.  

  • Community Member Profile Picture
    on at

    Hello sir ,

    I was writing it on the validate field post handler , but its was not working ..

  • Community Member Profile Picture
    on at

    ..

  • WillWU Profile Picture
    22,361 on at

    Hi UDIT,

    You could follow Sukrut's suggestion and write your code in the modified event handler.

    pastedimage1588671804609v1.png

    Hope this helps.

  • Suggested answer
    Obed Miranda Picado Profile Picture
    on at

    Hi. Can you give it a quick look to this docu https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/validations-defaults-unmapped-fields

    Validations can be defined on the tables that back up entities, at both the field level and the record level. Validations can also be defined at the data entity level.

  • Community Member Profile Picture
    on at

    I dont want it at data entities , I want to perform validation at table or form level ..

  • Obed Miranda Picado Profile Picture
    on at

    Hello,

    Please check the documentation provided again on https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/validations-defaults-unmapped-fields#validations You would want to use the validateWrite method to do the validation at the table level.  

    There is also a validateWrite method on the FormDataSource object which you could leverage if you want to validate at the form level https://docs.microsoft.com/en-us/dynamicsax-2012/developer/methods-on-a-form-data-source
  • Community Member Profile Picture
    on at

       [FormDataSourceEventHandler(formDataSourceStr(ProjInvoiceTable, PSAContractLineItems), FormDataSourceEventType::ValidatedWrite)]

       public static void PSAContractLineItems_OnValidatedWrite(FormDataSource sender, FormDataSourceEventArgs e)

       {

           FormRun                     formRun     =   sender.formRun();

           FormDataSource              formDataSource  =  

           formRun.dataSource(formDataSourceStr(ProjInvoiceTable,PSAContractLineItems ));

           PSAContractLineItems        psaContractLineItems,psaContractLineItems1    =   formDataSource.cursor();

           FXProjFundingSourcePOLines fxProjFundingPOLines  ;

           real                        a, b;

           if(fieldNum(PSAContractLineItems, LineValue))

           {

               select sum(BaseAmount) from FXProjFundingPOLines

               where fXProjFundingPOLines.ContractId == psaContractLineItems1.ProjInvoiceProjId;

               a = fxProjFundingPOLines.BaseAmount;

               select sum(LineValue) from psaContractLineItems

                   where psaContractLineItems.ProjInvoiceProjId == psaContractLineItems1.ProjInvoiceProjId;

               b = psaContractLineItems.LineValue;

               if(b > a)

               {

                   checkFailed("Wrong");

               }

           }

       This is my code suggest me the right code please

  • Community Member Profile Picture
    on at

       [FormDataSourceEventHandler(formDataSourceStr(ProjInvoiceTable, PSAContractLineItems), FormDataSourceEventType::ValidatedWrite)]

       public static void PSAContractLineItems_OnValidatedWrite(FormDataSource sender, FormDataSourceEventArgs e)

       {

           FormRun                     formRun     =   sender.formRun();

           FormDataSource              formDataSource  =  

           formRun.dataSource(formDataSourceStr(ProjInvoiceTable,PSAContractLineItems ));

           PSAContractLineItems        psaContractLineItems,psaContractLineItems1    =   formDataSource.cursor();

           AcxProjFundingSourcePOLines acxFundingPOLines  ;

           real                        a, b;

           if(fieldNum(PSAContractLineItems, LineValue))

           {

               select sum(BaseAmount) from FXProjFundingPOLines

               where FXProjFundingPOLines.ContractId == psaContractLineItems1.ProjInvoiceProjId;

               a = acxFundingPOLines.BaseAmount;

               select sum(LineValue) from psaContractLineItems

                   where psaContractLineItems.ProjInvoiceProjId == psaContractLineItems1.ProjInvoiceProjId;

               b = psaContractLineItems.LineValue;

               if(b > a)

               {

                   checkFailed("Wrong");

               }

           }

       This is my code suggest me the right code please

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 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans