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

GetCaml method of Value class doesn't add <Value> tag unless IncludeTimeValue hasValue #9

Closed
gsalatino opened this issue Jun 24, 2018 · 1 comment
Assignees
Labels

Comments

@gsalatino
Copy link

gsalatino commented Jun 24, 2018

Hi! The API is beautiful. It's really light and simple to use.

I would just like to point out that there is a Xml render issue when Value doesn't need to include time value. In this case, the Value tag isn't rendered:

        internal string GetCaml()
        {
            var sb = new StringBuilder();

            if (IncludeTimeValue.HasValue)
            {
                sb.AppendLine($"<Value Type='{Type}' IncludeTimeValue='{(IncludeTimeValue.Value ? "TRUE" : "FALSE")}'>");
            }

            sb.AppendLine(GetCamlValue());
            sb.AppendLine("</Value>");

            return sb.ToString();
        }

I've a workaround the issue. It's an ad-hoc solution for queries that not involve a datetime field as part of where clause. Here is it:

      var value = Value.ObjectValue(ValueType.Text, true, filterValue); 
      var viewXml = Query
        .Build(Operator.Equal("fieldName", value))
        .GetCaml()
        .Replace(" IncludeTimeValue='TRUE'", string.Empty);

It would be great if you can fix it, perhaps just by adding:

            else
            {
                sb.AppendLine($"<Value Type='{Type}'>");
            }

Thanks in advance!

@joaope joaope self-assigned this Jun 26, 2018
@joaope joaope added the bug label Jun 26, 2018
@joaope joaope closed this as completed in 039ff96 Jun 26, 2018
joaope added a commit that referenced this issue Jun 26, 2018
@gsalatino
Copy link
Author

gsalatino commented Jul 3, 2018

Thank you very much for your quick response! The fix works great!

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

No branches or pull requests

2 participants