Hi,
Did anyone has idea which method is called on updating the role id in project resources under resource list?
Thanks!!
Please mark the helpful answers as verified, so that others can make use of it.
Thanks,
Girish S.
Thanks its resolved.
Just commented line 17.
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.
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!!
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.
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();
}
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.
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!!
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.
André Arnaud de Cal...
291,979
Super User 2025 Season 1
Martin Dráb
230,848
Most Valuable Professional
nmaenpaa
101,156