Skip to content

Commit

Permalink
add ICDS_DATETIME_VALUE
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuliya Pazniak committed Jan 30, 2025
1 parent 30f58dd commit e0f8abb
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 12 deletions.
39 changes: 39 additions & 0 deletions datapress/Forms/custom-forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,45 @@ For example, you have several custom fields: `cr1d1_dateonly` - Date Only format

Then you view page with this template. To fill in this form you should type content in Date only field in `yyyy-mm-dd` or `yyyy/mm/dd` format (like `2023-01-20` or `2023/01/20`), Date Time field in `yyyy-mm-ddThh:mm` format (like `2023-01-20T12:30`).

When using the User Local behavior, all columns will display date or date-time fields converted to the specified time zone in case of the **Local** option in `ICDS_DATETIME_VALUE`. [More details](/datapress/administration/troubleshooting.md)

| | Legacy | UTC | Local |
|-----------------|------------|-------------------|--------|
|cr1d1_datetime | UTC | UTC | convert the date and time to the user's timezone |
|cr1d1_datetime_utc | UTC | UTC | UTC |
|cr1d1_datetime_local | convert the date and time to the user's timezone | convert the date and time to the user's timezone | convert the date and time to the user's timezone |

To display only a date or time column value, use the following code snippet:

```php
<div class="form-group">
<label>
dateuserlocal date utc:
<input class="form-control" name="cr1d1_datetime_utc_date" value="{{ currentRecord["cr1d1_datetime_utc_date"] }}">
</label>
</div>
<div class="form-group">
<label>
dateuserlocal date local:
<input class="form-control" name="cr1d1_datetime_local_date" value="{{ currentRecord["cr1d1_datetime_local_date"] }}">
</label>
</div>

<div class="form-group">
<label>
dateuserlocal time utc:
<input class="form-control" name="cr1d1_datetime_utc_time" value="{{ currentRecord["cr1d1_datetime_utc_time"] }}">
</label>
</div>

<div class="form-group">
<label>
dateuserlocal time local:
<input class="form-control" name="cr1d1_datetime_local_time" value="{{ currentRecord["cr1d1_datetime_local_time"] }}">
</label>
</div>
```

### Getting row GUID

After the row has been successfully created, you can get the guid using the redirect setting with the %s parameter.
Expand Down
8 changes: 7 additions & 1 deletion datapress/Forms/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,17 @@ When working with date and time values in forms, you can customize how they are

[Read more](https://learn.microsoft.com/en-us/power-apps/maker/data-platform/behavior-format-date-time-field)

When using the User Local behavior, all columns will display date or date-time fields converted to the specified time zone. For instance:
When using the User Local behavior, all columns will display date or date-time fields converted to the specified time zone in case of the **Legacy** or **Local** option in `ICDS_DATETIME_VALUE`. [More details](/datapress/administration/troubleshooting.md)

For instance:

If you have a value like **5/15/2028 03:00:00 AM** in a column with User Local behavior and set the time zone to **UTC + 2h**, the form will show **5/15/2028 05:00:00 AM**.
If you set the time zone to **UTC - 4h**, the form will display **5/14/2028 11:00:00 PM**.

| | Legacy | UTC | Local |
|-----------------|--------------|----------------|-----------|
|premium forms | convert the date and time to the user's timezone | UTC | convert the date and time to the user's timezone |

You can set time zones for **individual WordPress users**:

1. Find the user and click **Edit**.
Expand Down
24 changes: 23 additions & 1 deletion datapress/administration/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ For a more detailed analysis, you can download the logs by clicking `Download Lo

You can delete saved logs by clicking `Remove logs`.

### Advanced settings`
### Advanced settings
To configure advanced settings, navigate to the Dataverse Admin Area and open the `Settings` tab. At the bottom of the page, you will find `Advanced settings`.

Here are some of the key flags:
Expand All @@ -56,3 +56,25 @@ Here are some of the key flags:
- `ICDS_TWIG_USE_PRIVILEGES`- Use this flag to prevent editors and contributors from editing pages that access Dataverse data using twig code including but not limited to `view` and `fetchxml` tags. Existing page view permissions are preserved.

- `ICDS_TWIG_SUPPRESS_ERRORS` - If this flag is set to true, twig templates failing to compile or generating runtime errors will produce empty output.

- `ICDS_DISABLE_FETCHXML_LINKED_TABLES_EXPANSION` - If the flag is set to true, it is disable access to linked columns is via dotted notation, e.g. `contact.account.name`.

- `ICDS_DATETIME_VALUE` - Options to choose: **Legacy**, **UTC**, **Local**. Change behavior of User Local fields.

**Examples**:

| | Legacy | UTC | Local |
|-----------------|--------------|----------------|-----------|
| twig | UTC | UTC | convert the date and time to the user's timezone |
|views | UTC | UTC | convert the date and time to the user's timezone |
|custom forms | UTC | UTC | convert the date and time to the user's timezone |
|premium forms | convert the date and time to the user's timezone | UTC | convert the date and time to the user's timezone |


For more details:

[More details for twig](/datapress/using-twig/separate_columns_in_twig.md)

[More details for view](/datapress/views.md)

[More details for custom forms](/datapress/Forms/custom-forms.md)
23 changes: 13 additions & 10 deletions datapress/using-twig/separate_columns_in_twig.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@ keywords: [DataPress twig, decimal, float, currency, duration, choice]

## Displaying Column Values

### Get date column from CRM and transform its value
### Get date column from CRM

To display a column value in UTC, use the following Twig code snippet:
In Dataverse Admin Area you can manage display date and time. Pay attention to the `ICDS_DATETIME_VALUE` setting. It has several options: **Legacy**, **UTC**, **Local**.

```twig
{% set record=entities.contact["11c4c8fa-bf0e-ef11-9f89-0022489310b4"] %}
{{ record.createdon }}
```
Examples for the **createdon** column which has User Local behavior:

| | Legacy | UTC | Local |
|----------------------|--------------|----------------|-----------|
|`{{record.createdon}}` | UTC | UTC | convert the date and time to the user's timezone |
|`{{record.createdon_utc}}` | UTC | UTC | UTC |
|`{{record.createdon_local}}` | convert the date and time to the user's timezone | convert the date and time to the user's timezone | convert the date and time to the user's timezone |

To convert a column value to the user's timezone, use the `_local` suffix as shown below:
To display a column value for Time zone independent and Date only behavior , use the following Twig code snippet:

```twig
{% set record=entities.contact["11c4c8fa-bf0e-ef11-9f89-0022489310b4"] %}
{{ record.createdon_local }}
{{ record.createdon }}
```

Use `format_datetime()` to get value of any date column and transform its value.
Use `format_datetime()` to get the value of any date column and convert its value according to user's locale and timezone.

```twig
{% set record=entities.contact[GUID] %}
Expand All @@ -40,7 +43,7 @@ Example: we need to get Birthday column value and to see it as 11/1/22, 12:00 AM
{{ record.birthdate|format_datetime(dateFormat='short', timeFormat='short', locale=user.locale, timezone=user.timezone) }}
```

You can override the default timezone by explicitly specifying a timezone:
You can convert the default timezone by explicitly specifying a timezone:

```twig
{% set record=entities.contact[9ff7777f-6266-ed11-9562-00224892b4a1] %}
Expand Down
25 changes: 25 additions & 0 deletions datapress/views.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,31 @@ To display email addresses and URLs as active links, set the formatHyperlinks op
```php
{% view entity="contact" name="Active Contacts" formatHyperlinks=true count=100 %}{% endview %}
```
## How to display date or date-time column

When using the **User Local** behavior, all columns will display date or date-time columns converted to the specified time zone in case of the **Local** option in `ICDS_DATETIME_VALUE`. [More details](/datapress/administration/troubleshooting.md)

**Examples:**

To get the value of a date column and convert it to the user's time zone, use:

```php
{% view entity="account" name="All Accounts" datetime = 'local' %} {% endview %}
```

To get the value of a date column in UTC, use:

```php
{% view entity="account" name="All Accounts" datetime = 'utc' %} {% endview %}
```

**Comparison Table**

| | Legacy | UTC | Local |
|-----------------|------------|-------------------|--------|
|view | UTC | UTC | convert the date and time to the user's timezone |
|view with datetime = 'utc' | UTC | UTC | UTC |
|view with datetime = 'local' | convert the date and time to the user's timezone | convert the date and time to the user's timezone | convert the date and time to the user's timezone |

## Display data using a custom template

Expand Down

0 comments on commit e0f8abb

Please sign in to comment.