Skip to content

Commit

Permalink
Merge pull request #749 from AngelRodriguez8008/users/angel/fixSetDat…
Browse files Browse the repository at this point in the history
…eTimeValue

Fix Clear DateTime Field (Solve Issue #745)
  • Loading branch information
TYLEROL authored Feb 7, 2020
2 parents d31a2d8 + 89fd125 commit f7cb7d7
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ public DateTimeControl(string name)
Name = name;
}
public string Name { get; set; }
public DateTime Value { get; set; }
public DateTime? Value { get; set; }

public string DateFormat { get; set; }
public string TimeFormat { get; set; }

private string _dateAsString;
public string DateAsString {
get => _dateAsString ?? (_dateAsString = string.IsNullOrWhiteSpace(DateFormat) ? Value?.ToShortDateString() : Value?.ToString(DateFormat));
set => _dateAsString = value;
}

private string _timeAsString;
public string TimeAsString {
get => _timeAsString ?? (_timeAsString = string.IsNullOrWhiteSpace(TimeFormat) ? Value?.ToShortTimeString() : Value?.ToString(TimeFormat));
set => _timeAsString = value;
}
}
}
44 changes: 40 additions & 4 deletions Microsoft.Dynamics365.UIAutomation.Api.UCI/Elements/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ public void ClearValue(MultiValueOptionSet control)
{
_client.ClearValue(control);
}


/// <summary>
/// Clears a value from the DateTimeControl provided
/// </summary>
/// <param name="control"></param>
public void ClearHeaderValue(DateTimeControl control)
{
_client.ClearHeaderValue(control);
}

/// <summary>
/// Clears a value from the DateTimeControl provided
/// </summary>
/// <param name="control"></param>
public void ClearValue(DateTimeControl control)
{
_client.ClearValue(control);
}

/// <summary>
/// Close Record Set Navigator
Expand Down Expand Up @@ -159,12 +178,11 @@ public MultiValueOptionSet GetHeaderValue(MultiValueOptionSet control)
/// </summary>
/// <param name="control">The date time field name of the lookup.</param>
/// <example>xrmApp.Entity.GetValue(new DateTimeControl { Name = "estimatedclosedate" });</example>
public DateTime GetHeaderValue(DateTimeControl control)
public DateTime? GetHeaderValue(DateTimeControl control)
{
return _client.GetHeaderValue(control);
}



/// <summary>
/// Get the object id of the current entity
/// </summary>
Expand Down Expand Up @@ -214,7 +232,7 @@ public string GetValue(LookupItem control)
/// Gets the value of a Lookup.
/// </summary>
/// <param name="control">The lookup field name of the lookup.</param>
public DateTime GetValue(DateTimeControl control)
public DateTime? GetValue(DateTimeControl control)
{
return _client.GetValue(control);
}
Expand Down Expand Up @@ -393,6 +411,15 @@ public void SetHeaderValue(string field, DateTime date, string formatDate = null
_client.SetHeaderValue(field, date, formatDate, formatTime);
}

/// <summary>
/// Sets the value of a BooleanItem in the header
/// </summary>
/// <param name="control">The boolean field you want to set.</param>
public void SetHeaderValue(DateTimeControl control)
{
_client.SetHeaderValue(control);
}

/// <summary>
/// Sets the value of a field
/// </summary>
Expand Down Expand Up @@ -453,6 +480,15 @@ public void SetValue(string field, DateTime date, string formatDate = null, stri
_client.SetValue(field, date, formatDate, formatTime);
}

/// <summary>
/// Sets the value of a Date Field.
/// </summary>
/// <param name="control">Date field control.</param>
public void SetValue(DateTimeControl control)
{
_client.SetValue(control);
}

/// <summary>
/// Sets/Removes the value from the multselect type control
/// </summary>
Expand Down
Loading

0 comments on commit f7cb7d7

Please sign in to comment.