Skip to main content

Notifications

Announcements

No record found.

Supply chain | Supply Chain Management, Commerce
Unanswered

Update PositionWorkerAssignments Entity via. OData Not Working

Posted on by

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);

}

  • ToddB Profile Picture
    ToddB on at
    RE: Update PositionWorkerAssignments Entity via. OData Not Working

    Hi Anish,

    I will leave this here for the community to reply to your custom code question.

    If you are able to debut the code, please provide any additional information you find.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans