Skip to content

Commit

Permalink
add resettable properties
Browse files Browse the repository at this point in the history
  • Loading branch information
peggy-quartech committed Nov 30, 2024
1 parent ef33ece commit 79e1677
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Spd.Utilities.Dynamics/ODataClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace Spd.Utilities.Dynamics
internal class ODataClientHandler(ISecurityTokenProvider tokenProvider) : IODataClientHandler
{
private string? authToken;
private static readonly string[] resettableProperties = {
"spd_requestdogsreasons",
"spd_requestdogs" };

public void OnClientCreated(ClientCreatedArgs args)
{
Expand All @@ -17,7 +20,8 @@ public void OnClientCreated(ClientCreatedArgs args)
client.Configurations.RequestPipeline.OnEntryStarting((arg) =>
{
// do not send reference properties and null values to Dynamics
arg.Entry.Properties = arg.Entry.Properties.Cast<ODataProperty>().Where((prop) => !prop.Name.StartsWith('_') && prop.Value != null);
arg.Entry.Properties = arg.Entry.Properties.Cast<ODataProperty>()
.Where((prop) => !prop.Name.StartsWith('_') && ((resettableProperties.Contains(prop.Name) && prop.Value == null) || prop.Value != null));
});
client.BuildingRequest += Client_BuildingRequest;
client.SendingRequest2 += Client_SendingRequest2;
Expand Down

0 comments on commit 79e1677

Please sign in to comment.