diff --git a/jumpcloud/resource_user.go b/jumpcloud/resource_user.go index e19ce20..71e9e3d 100644 --- a/jumpcloud/resource_user.go +++ b/jumpcloud/resource_user.go @@ -226,13 +226,16 @@ func resourceUserUpdate(d *schema.ResourceData, m interface{}) error { } // Dynamically set the display name if there's a change - if d.HasChange("display_name") { - if displayName, ok := d.GetOk("display_name"); ok { - payload.Displayname = displayName.(string) - } else { - payload.Displayname = "" // Clear display name if not provided in the config - } - } + if d.HasChange("display_name") { + _, ok := d.GetOk("display_name") + if !ok { + // The attribute was removed from the configuration, so we explicitly clear it. + payload.Displayname = "" + } else { + // The attribute has a new value. + payload.Displayname = d.Get("display_name").(string) + } + } req := map[string]interface{}{ "body": payload,