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

Community site session details

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

Help with validateField() logic

(0) ShareShare
ReportReport
Posted on by 2

 public boolean validateField(FieldId _fieldIdToCheck)
    {
        boolean ret;
        ret = next validateField(_fieldIdToCheck);
        TaxInformationVendTable_IN tax;
        if(_fieldIdToCheck == fieldNUm(TaxInformationVendTable_IN, PanNumber))
        {
            while select RecId , PANNumber , VendTable from tax
                where tax.VendTable != this.VendTable
                && tax.PanNumber == this.PaNNumber
            {
                if(tax)
                {
                    ret = false;
                    Info(strFmt("@OAB:OABPanNumberExist",tax.PANNumber,tax.vendtable,VendTable::find(tax.VendTable).vendorName()));
                }
            }
        }
        return ret;
    }

  1. For a new record, if the PAN Number field is kept blank system shall not check other records.
  2. This pop-up shall only be as a warning and shall allow to create and save record even if the same PAN exist in other records,
I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: Need Help with Code D365F&O

    Hi Sachin Mittal,

    Can you elaborate more on the issue?

    You just added info - If you want to allow the user to save the record if the same PAN exist for other records, then ret must return true.

    On your code refer to line number 14 - ret buffer must be set to true then only it will allow you to the save the record.

    Thanks,

    Girish S.

  • Sachin Mittal Profile Picture
    2 on at
    RE: Help with validateField() logic

    hi , after uisng advice by you , info is printing record two times

    pastedimage1673602706351v1.png

    pastedimage1673602734852v2.png

  • Martin Dráb Profile Picture
    236,960 Most Valuable Professional on at
    RE: Help with validateField() logic

    You can use the "if" statement to run your logic only if PAN Number is set. If you don't want to fail the validate, don't set ret to false.

    For example:

    public boolean validateField(FieldId _fieldIdToCheck)
    {
    	boolean ret = next validateField(_fieldIdToCheck);
    	 
    	switch (_fieldIdToCheck)
    	{
    		case fieldNUm(TaxInformationVendTable_IN, PanNumber):
    			if (this.PanNumber)
    			{
    				TaxInformationVendTable_IN tax;
    
    				while select PANNumber, VendTable from tax
    					where tax.VendTable != this.VendTable
    					   && tax.PanNumber == this.PanNumber
    				{
    					info(strFmt("@OAB:OABPanNumberExist", tax.PanNumber, tax.vendTable, VendTable::find(tax.VendTable).vendorName()));
    				}
    			}
    			break;
    	}
    
    	return ret;
    }

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Help with validateField() logic

    Info is not printing 2 times - I guess totally 6 vendors has same PAN number as you have given in the form.

    Thanks,

    Girish S.

  • Sachin Mittal Profile Picture
    2 on at
    RE: Help with validateField() logic

    no , i have also added screenshot inmf9 , inmf7 ,inmf3 is printing two times

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Help with validateField() logic

    Please debug the code and confirm that the while select you have added is looping 3 times only based on your record.

    Thanks,

    Girish S.

  • Sachin Mittal Profile Picture
    2 on at
    RE: Help with validateField() logic

    it is looping 6 times

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Help with validateField() logic

    I am not sure why its looping 6 times. Open "TaxInformationVendTable_IN" in table browser and see how many records against that PAN number - On the table "TaxInformationVendTable_IN" - "Vendor" field is unique. So, I don't think data might not be the issue.

    Please review the while select statement you added.

    Thanks,

    Girish S.

  • Sachin Mittal Profile Picture
    2 on at
    RE: Help with validateField() logic

    when ret was false it was showing info only one time , when ret is true its showing two times

  • Martin Dráb Profile Picture
    236,960 Most Valuable Professional on at
    RE: Help with validateField() logic

    Why is it in validateField() at all? Will you have the same problem in modifiedField() (which sounds like a better place)?

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 580 Most Valuable Professional

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 554

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans