connect 2022 banner tablet connect 2022 banner mobile

Using PSAResourceTable in Dynamics AX Project Management and Accounting Module

By Mark Nelson | May 1, 2015

The PSAResourceTable is used often in the Project Management & Accounting module.  It holds a list of valid worker resources and is used when assigning workers to tasks.  What isn't immediately clear is how to use it.  The first problem is that it is used like a temp table, but it isn't defined as a temp table.  Instead, it has a Guid field called UserSesssion that controls who will see the records.  You also won't easily find any insert statements inserting records into the table.  That is where the ProjProjectResourceList class comes in.  This class is responsible for populating the PSAResourceTable and deleting the records when you are done.

To see this in action you will first need to add some workers as project resources.  Go to Project management and accounting/Common/Project resources/Resources and click the Resource button on the Action Pane.
New Resource

Add a few resources by choosing appropriate values for each field and press OK.  When you are done you should see something like this.
Resources_PSAResourceTable

Now we can query the PSAResourceTable for our resources.
private void findResources()

{

PSAResourceTable resources;

HcmWorker hcmWorker;

ProjIProjectResourceList resourceList;

guid userSession;

utcDateTime startDateTime;

utcDateTime endDateTime;

// This Guid is used to filter the table to just our results.

userSession = newGuid();

// Construct the ProjProjectResourceList

resourceList = ProjProjectResourceList::construct(userSession);

  // These dates are used to filter the workers

startDateTime = DateTimeUtil::getSystemDateTime();

endDateTime = DateTimeUtil::maxValue();

// Populate the PSAResourceTable

resourceList.getResources(startDateTime, endDateTime);

// Now we can query the table for our resources.

while select Resource, ResourceCalendar, ResourceDataArea, LegalEntity from resources

where resources.UserSession == userSession

&& resources.ResourceSet == ProjResourceSet::Cache

  join HcmWorker

where HcmWorker.RecId == resources.Resource

{

info(HcmWorker.name());

}

// Our records will remain in the table until we clear them out because this

   // isn't a real temp table.

resourceList.clearResources();

resourceList.clearResourceSet();

}

Make sure you call clearResources and clearResourceSet when you are finished with the table so you don't pollute it with orphaned records.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X