web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Update PositionWorkerAssignments Entity via. OData Not Working

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Below code is written for updating "validTo" field for PositionWorkerAssignments entity in D365.

However no error is thrown, but data is not updated in the table/entity.

var query = Context.PositionWorkerAssignments.Where(s => s.PersonnelNumber == associate.PersonNumber) as DataServiceQuery<PositionWorkerAssignment>;
var response = await query.ExecuteAsync().ConfigureAwait(false);
var workerAssignment = response.FirstOrDefault();

if (workerAssignment != null)
{
var workerAssignmentCollection = new DataServiceCollection<PositionWorkerAssignment>(Context);
workerAssignmentCollection.Add(workerAssignment);


workerAssignment.ValidTo = DateTime.UtcNow.Date; //ending assignment


Context.UpdateObject(workerAssignment);
var saveResponse = await Context.SaveChangesAsync(SaveChangesOptions.PostOnlySetProperties).ConfigureAwait(false);

}

I have the same question (0)
  • Suggested answer
    Parag Chapre Profile Picture
    12,254 Most Valuable Professional on at

    Hi Anish,

    I am not sure how this handles in Odata but when updating Valid To value you need to consider whether you want to create a new record, correction. This table is Date effective.

  • AnishKM Profile Picture
    Microsoft Employee on at

    But even if we need to add a new record? should we end(update) the initial assignment?

  • Parag Chapre Profile Picture
    12,254 Most Valuable Professional on at

    As per my information, When you create a new record then it adjusts the previous record and creates a new record.

    When you edit the record then it just adjusts the current record.

    Please check the data entity methods and try to debug the code.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 276 Most Valuable Professional

#3
Anton Venter Profile Picture

Anton Venter 225 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans