Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Create Benefit issue

Posted on by 40

Facing strange issue during creating benefit plan from outside(using insert code). Total number of rows inserted properly with data but unable to view data on forms. its shows display unknown values in every fields. I have perform every possible solution to fix it but in vain.

While adding from button its add perfect. It will be appreciated if anyone can share solution with me.

benefitIssue.JPG

My code is ....

public void createBenifitPlan(RefRecId _worker, StartDateTime _startDateTime, EndDateTime _endDateTime, Amount _amount)
{
HcmWorkerEnrolledBenefit hcmWorkerEnrolledBenefit;
PayrollWorkerEnrolledBenefitDetail payrollWorkerEnrolledBenefitDetail;


hcmWorkerEnrolledBenefit.Worker = _worker;
hcmWorkerEnrolledBenefit.Benefit = 5637146078;//5637144580;
hcmWorkerEnrolledBenefit.ValidFrom = _startDateTime;
hcmWorkerEnrolledBenefit.ValidTo = _endDateTime;
hcmWorkerEnrolledBenefit.insert();

payrollWorkerEnrolledBenefitDetail.WorkerEnrolledBenefit = hcmWorkerEnrolledBenefit.RecId;
payrollWorkerEnrolledBenefitDetail.LegalEntity = CompanyInfo::current(curExt());
payrollWorkerEnrolledBenefitDetail.DeductionAmountCur = _amount;
PayrollWorkerEnrolledBenefitDetail.DeductionRateSource = PayrollBenefitRateSource::Custom;
payrollWorkerEnrolledBenefitDetail.DeductionBasis = PayrollDeductionBasis::FixedAmount;
payrollWorkerEnrolledBenefitDetail.ValidFrom = DateTimeUtil::date(_startDateTime);
payrollWorkerEnrolledBenefitDetail.ValidTo = DateTimeUtil::date(_endDateTime);
payrollWorkerEnrolledBenefitDetail.insert();
}


*This post is locked for comments

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Create Benefit issue

    Did you compare the records in table browser, so that you will find the difference between your x++ created records and those that are created from UI? Did you find any difference? Maybe you could share your current code, and screenshots of the table browser?

  • Majid Hafeez Profile Picture
    Majid Hafeez 40 on at
    RE: Create Benefit issue

    Nikolaos, I have followed your provided link community.dynamics.com/.../258027

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Create Benefit issue

    What exactly did you try? Several things were suggested.

  • Majid Hafeez Profile Picture
    Majid Hafeez 40 on at
    RE: Create Benefit issue

    No effected same issue exist.

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Create Benefit issue

    Hi!

    Try to synchronise table and restart AOS.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Create Benefit issue

    Generally if you find issues when inserting data in code, you should always use the table browser to compare records that were created from the user interface, and records that you created in code. Most likely you will see some difference, and can then adjust your code accordingly.

    For this specific case, it seems you might no need to add a third table to make it work: https://community.dynamics.com/ax/f/33/t/258027  

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans