Skip to main content

Notifications

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

which method is called on updating the role id in project resources under resource list

(0) ShareShare
ReportReport
Posted on by 167

Hi,

Did anyone has idea which method is called on updating the role id in project resources under resource list?

Thanks!!

pastedimage1679291847505v2.png

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: which method is called on updating the role id in project resources under resource list

    Please mark the helpful answers as verified, so that others can make use of it.

    Thanks,

    Girish S.

  • D365 ER Profile Picture
    D365 ER 167 on at
    RE: which method is called on updating the role id in project resources under resource list

    Thanks its resolved.

    Just commented line 17.

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: which method is called on updating the role id in project resources under resource list

    You need to mention the ValidTimeStateUpdateMode while updating valid time state tables. Check my code I have added that. Refer to line number 17 on my code.

    Thanks,

    Girish S.

  • D365 ER Profile Picture
    D365 ER 167 on at
    RE: which method is called on updating the role id in project resources under resource list

    Hi,

    Thanks for the correction but getting the error while updating.

    Cannot edit a record in Employment (HcmEmployment). Update on a valid time state table is not allowed without specifying a ValidTimeStateUpdateMode.

    Thanks!!

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: which method is called on updating the role id in project resources under resource list

    No need to insert the record. For the selected resource there will be a record in the employment table. You need to do an update on the employment table against that worker.

    [DataEventHandler(tableStr(ResourceResourceCategorySetupTable), DataEventType::Inserted)]
    public static void ResourceResourceCategorySetupTable_onInsertod(Common sender, DataEventArgs e)
    {
        ResourceResourceCategorySetupTable category = sender as ResourceResourceCategorySetupTable;
        PSASchedRole roleTable1 = PSASchedRole::find(category.ResourceCategory);
        ResourceView resource;
        HcmEmployment employment;
        
        select * from resource
            where resource.Resource = category.Resource;
        select forupdate * from employment
            where employment.worker == resource.Worker;
        if(employment)
        {
            ttsbegin;
            employment.WERoleId = roleTable1.RoleId;
            employment.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
            employment.update();
            ttscommit;
        }
    }
    

    Thanks,

    Girish S.

  • D365 ER Profile Picture
    D365 ER 167 on at
    RE: which method is called on updating the role id in project resources under resource list

    Hi Girish ,

    I used the event handler on inserted...But I am getting the below error.

    Cannot create a record in Employment (HcmEmployment). Insert not supported with the values specified for 'Employment start date' and 'Employment end date'. New record overlaps with multiple existing records.

    Let me know if my code is correct.

    select Resource from resourceResourceCategorySetup

             join resourceView

             join hcmEmployment

             where resourceView.RecId == resourceResourceCategorySetup.Resource

             && resourceView.Worker == hcmEmployment.Worker

             && resourceResourceCategorySetup.ValidTo >= today()

                           && resourceResourceCategorySetup.ValidFrom <= today()

      PSASchedRole roleTable1 = PSASchedRole::find(resourceResourceCategorySetup.ResourceCategory);

           hcmEmployment.WERoleId = roleTable1.RoleId;

           if(hcmEmployment)

           {

               hcmEmployment.WERoleId = roleTable1.RoleId;

               hcmEmployment.doinsert();

           }

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: which method is called on updating the role id in project resources under resource list

    RoleId is not inserted or updated from ResResourcesListView.. Role Id is inserted or updated from ResourceResourceCategorySetup table.

    On the same form you have posted there is a menu item name Resource role. In that form only they will add Rold Id.

    So you can add your code OnInserted and OnUpdated event handler of ResResourceCategorySetupTable to update the RoleId on the HcmEmployment table.

    Thanks,

    Girish S.

  • D365 ER Profile Picture
    D365 ER 167 on at
    RE: which method is called on updating the role id in project resources under resource list

    Thanks for the reply....my requirement is I have new field as  role id  in HCMEmployment table and on updating or inserting the role Id from ResResourcesListView I want to update the same in HCM employment.

    Suggest me the ways to achieve it as we can't write any insert or update method on views.

    Thanks!!

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: which method is called on updating the role id in project resources under resource list

    Hi

    Seems Role Id in the Resource list page form is a display method.

    Refer to the display method getResourceCategoryId on ResResourcesListView DataSource of ResResourceListPage form.

    Role Id is fetched from the ResourceResourceCategorySetUp table.

    Thanks,

    Girish S.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans