Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set specific fields to null for a big object during update/upsert #388

Open
skynetit opened this issue Oct 2, 2020 · 1 comment

Comments

@skynetit
Copy link

skynetit commented Oct 2, 2020

We have scenarios where we will update only specific attributes on the contact object. In those cases, we will populate only those required properties in the object. Currently ForceClient allows to set NullValueHandling as a whole not for specific attributes.

What if ForceClient update/upsert method takes a parameter for the list for fields that needs to be update as null and UpdateableContractResolver sets the property.NullValueHandling = NullValueHandling.Include for the property present in the parameter.

something like

public class UpdateableContractResolver : DefaultContractResolver
{
        private List<string> fieldsToNull;
        public UpdateableContractResolver(List<string> fieldsToNull)
        {
            this.fieldsToNull = fieldsToNull;
        }

       protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
        {
            JsonProperty result = base.CreateProperty(member, memberSerialization);

            if (fieldsToNull.Contains(result.PropertyName))
            {
                result.NullValueHandling = NullValueHandling.Include;
            }

            return result;
        }
}
 

Is it possible to to? In this way, we will have the ability to update the specific fields to null in SF. mainly for DateTime field where we need to create it as string field in c# class to update as null

@skynetit
Copy link
Author

Any updates or suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant