Skip to main content

Notifications

Announcements

No record found.

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

Issue in using LeaveRecord() mehtod x++

Posted on by 343
I added a new customize fields (Location , Availability ) in Loan Item Form and set them mandatory , I need user can't leave this loan item if Location or Availability is empty .
So I added my validation in leave record method of loan item data source , but when I searched for specific loan item I got error of mandatory fields then I tried to add data on it but no thing happens fields doesn't accept data it still empty .
 
 
    public boolean leaveRecord(boolean _ForUpdate)
    {
        boolean ret;
         ret = next leaveRecord(_ForUpdate);
        HcmLoanItem HcmLoanItem = this.cursor();
 
      if (HcmLoanItem.AllocationType == 'Project' && !HcmLoanItem.Location)
           ret = CheckFailed(/Location filed must be filled in /);
        
        if (HcmLoanItem.AllocationType == 'Project' && !HcmLoanItem.Availability)        
           ret   =  CheckFailed(/Availability filed must be filled in /);
     
        return ret;
    }
 
 
  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,605 Super User 2024 Season 1 on at
    Issue in using LeaveRecord() mehtod x++
    Please let us know if you need more help on this and mark the helpful answers as verified.
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,332 Super User 2024 Season 2 on at
    Issue in using LeaveRecord() mehtod x++
     
    Your logic should be in validateField and validateWrite methods.
     
     
    Regards,
    Waed Ayyad
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    Issue in using LeaveRecord() mehtod x++
    The correct place for such validations is validateWrite() method.

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