Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

How to solve validateWrite methods in ax 2012?

Posted on by 1,213

Hi , guys

i wrote a validatewrite in the datasource some validation when i click add button same validation msg getting again i can't fill the "Contact information details" 

what to be done?

boolean ret;
HcmApplicant applicant;
DirPerson person;
DirPersonName personName;
LogisticsElectronicAddress electronicAddress;
DirPartyTable dirPartyTable;
ret = super();

select firstOnly applicant
join Person where applicant.Person == person.RecId
&& applicant.ApplicantId == HcmApplicant.ApplicantId
join personName where personName.Person == person.RecId
join dirPartyTable where dirPartyTable.RecId == person.RecId
join electronicAddress where electronicAddress.PrivateForParty == dirPartyTable.RecId;
if (!electronicAddress.RecId)
ret = checkFailed("Contact information should be filled for new applicant.");

return ret;

 

regards,

Riyas ahamed F

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to solve validateWrite methods in ax 2012?

    The applicant record must be saved before you can create a contact person that is associated to it. So you can't have such logic in validateWrite of Applicant, that would require a contact person to exist. It will always fail.

    Also, when you are on this form, and enter some Applicant info, the record is not yet saved. However when the focus moves away from the Applicant record, to the newly created Contact person record, the system attempts to save the Applicant. This fails because contact person doesn't exist.

    You have to solve your business requirement in some other way.

  • Riyas ahamed F Profile Picture
    Riyas ahamed F 1,213 on at
    RE: How to solve validateWrite methods in ax 2012?

    6445.image-_2800_1_2900_.png

    7026.image-_2800_2_2900_.png

    in this error when i click the contact person details same error came again also i need it in the header all fill the mandatory when i save record getting error "Contact person fill" once again i fill the contact person same error again came??  

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to solve validateWrite methods in ax 2012?

    validateWrite is executed before the record is saved (insert/update). This is to prevent users from creating data that is not allowed, according to your validation rules.

    Your select statement doesn't seem to have any link to any record on your form. All table buffers that you use are initialized in your validateWrite method, which means you don't get anything from the actual form data source. So it will always return the same result, no matter what kind of data you have on your form.

    As usual, let's take one step back and start from your business requirement. What is your business requirement? What are you trying to achieve functionally?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans