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

DateTime Sub-Type added to <remarks> in generated fields/entities #509

Open
PC-BPS opened this issue Jul 17, 2024 · 3 comments
Open

DateTime Sub-Type added to <remarks> in generated fields/entities #509

PC-BPS opened this issue Jul 17, 2024 · 3 comments

Comments

@PC-BPS
Copy link

PC-BPS commented Jul 17, 2024

What tool/version is it that you're making a feature request for?

EarlyBoundGenerator

Is your feature request related to a problem? Please describe.

When we try to write code for a mix of DateTimes (TimeZone Independent) and Date Only, we have to check the solution to confirm the type of DateTime before working on it. It is easy to make a mistake and accidentally set something to the UTC Date instead of our own local date (AEST). Records that are created or updated prior to 10am will have the day priors date.

Existing generated field:

/// <summary>
/// Start Date of Product
/// </summary>
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("new_startdate")]
public System.Nullable<System.DateTime> new_startdate
{
	[System.Diagnostics.DebuggerNonUserCode()]
	get
	{
		return this.GetAttributeValue<System.Nullable<System.DateTime>>("new_startdate");
	}
	[System.Diagnostics.DebuggerNonUserCode()]
	set
	{
		this.SetAttributeValue("new_startdate", value);
	}
}

Describe the solution you'd like

When the earlybound entities and fields are generated, the comments of the field show that it is either TimeZone Independent or DateOnly. It would be great if it were configurable, so that a custom message could be shown for either situation.

Example:

/// <summary>
/// Start Date of Product
/// </summary>
 /// <remarks>
/// DateOnly - When dealing with UTC dates, convert using CustomUtility.ConvertToAEST()
/// </remarks>
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("new_startdate")]
public System.Nullable<System.DateTime> new_startdate
{
	[System.Diagnostics.DebuggerNonUserCode()]
	get
	{
		return this.GetAttributeValue<System.Nullable<System.DateTime>>("new_startdate");
	}
	[System.Diagnostics.DebuggerNonUserCode()]
	set
	{
		this.SetAttributeValue("new_startdate", value);
	}
}

Describe alternatives you've considered
Changing the description of each field that is DateOnly in the solution, so that it shows in the <summary>.

@daryllabar
Copy link
Owner

Hmm... When dealing with Dates in the SDK, they should always be set as UTC, and retrieved as UTC. What exactly is the conversion logic that you are applying and for which Date field formats? I'm wondering if there is a better approach that can be built in, or maybe an attribute metadata type that can at least be added.

@PC-BPS
Copy link
Author

PC-BPS commented Sep 9, 2024

When we create a record prior to 10AM local time. If that record contains a date only field, the value is set to the day before. So in order for the date to be "Today" we have to add 10 hours to it.

It is difficult to identify which fields we need to do this to, we have to go look it up in the solution.

@daryllabar
Copy link
Owner

Does this not work?

entity.myDate = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);

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

No branches or pull requests

2 participants