web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Changing available time intervals on a DateTime field

(0) ShareShare
ReportReport
Posted on by 229

Hello community,

I'm aware that this is probably not supported, but is there a way (even if it's not offically supported) to configure the interval for the Time picker element on a DateTime field in UCI? 

By default this is set to half hour intervals:

11:30
12:00
12:30
and so on

and we'd like to change this to 5 minute intervals.

11:05
11:10
11:15
and so on

is this possible outside of "create your own datetime picker webressource and tell it to store it's value in the original field, and hide that original field from users"?

I have the same question (0)
  • erhan.keskin Profile Picture
    2,253 on at

    Hi,

    There is no supported way to change those selections on the control. What you can do is to create an Option Set with the values you want, and populate the date time field in a jscript method depending on the selection in the option set.

    Regards,

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    The supported way is available but you will have to develop own PCF control for that purpose.

    If you want to go that path - you can check videos I published on my channel - www.youtube.com/.../AndrewButenko

  • Verified answer
    erhan.keskin Profile Picture
    2,253 on at

    Hi,

    Yes, it seems you can create your own control with PowerApps Component Framework: docs.microsoft.com/.../overview

    There is a gallery of PCFs, check this out: https://pcf.gallery/

    This not exactly what you asked, but might interest you, please have a look: https://pcf.gallery/time-picker/

    Regards,

  • DKasp Profile Picture
    229 on at

    First of all thank you for the links and the videos, those helped me a lot just now! :-)

    I do have an issue with my new PCF control though, and I can't find any references or helpful information on this specific issue:

    my manifest contains this property:

    and my code properly the value when entered, and it shows up as a Date which i then parse to this.date.value (an input of type Date) and this.time.value (an input of type Time):

    var dateTime = context.parameters.dateTime.raw;

    This does work decently well, but I'm unable to get the Outputs working correctly. 

    	public getOutputs(): IOutputs
        {
            if (this.date.valueAsDate != null && this.time.valueAsDate != null) {
    
                var dateTime = new Date(this.date.valueAsNumber   this.time.valueAsNumber);
                
                return {
    
                    dateTime: dateTime
                };
            } else {
                return { dateTime: undefined }
            }
    	}

    VS says dateTime must be null or a Date, and I'm handing over a Date object that seems to be working just fine (it properly adds time and date together and shows the correct dateTime when debugging),

    But I always get an error once that's through: 

    Invariant Violation: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=Tue Jan 01 2019 13:01:00 GMT 0100 (MitteleuropåA4ische Normalzeit)&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings. 
        at pb (http://127.0.0.1:8181/lib/react-dom.production.min.js:12:454)
        at n (http://127.0.0.1:8181/lib/react-dom.production.min.js:13:221)
        at Ac (http://127.0.0.1:8181/lib/react-dom.production.min.js:70:369)
        at http://127.0.0.1:8181/lib/react-dom.production.min.js:80:190
        at N (http://127.0.0.1:8181/lib/react-dom.production.min.js:89:471)
        at hi (http://127.0.0.1:8181/lib/react-dom.production.min.js:105:408)
        at Qg (http://127.0.0.1:8181/lib/react-dom.production.min.js:144:217)
        at Rg (http://127.0.0.1:8181/lib/react-dom.production.min.js:145:76)
        at Sc (http://127.0.0.1:8181/lib/react-dom.production.min.js:158:109)
        at Z (http://127.0.0.1:8181/lib/react-dom.production.min.js:156:492)
        at Kc (http://127.0.0.1:8181/lib/react-dom.production.min.js:155:52)
        at ya (http://127.0.0.1:8181/lib/react-dom.production.min.js:153:159)
        at Object.enqueueSetState (http://127.0.0.1:8181/lib/react-dom.production.min.js:202:409)
        at t.setState (http://127.0.0.1:8181/lib/react.production.min.js:20:433)
        at t.onOutputChange (http://127.0.0.1:8181/harness.js:11:278194)
        at http://127.0.0.1:8181/harness.js:11:353546

    following the Decoder link it tells me the error is:

    Objects are not valid as a React child 

    but how else am I supposed to hand over the value for the underlying DateAndTime.DateAndTime field?

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Can you please provide your full code?

  • DKasp Profile Picture
    229 on at

    Gladly - sorry for the lack of formatting, but it appears that the rich formatting broke on this board...

    import {IInputs, IOutputs} from "./generated/ManifestTypes";

    import * as $ from "jquery";

    import { Component } from "react";

    export class TimePicker implements ComponentFramework.StandardControl<IInputs, IOutputs> {

       private date: HTMLInputElement;

       private time: HTMLInputElement;

       private notifyOutputChanged: () => void;

    constructor()

    {

    }

    /**

    * Used to initialize the control instance. Controls can kick off remote server calls and other initialization actions here.

    * Data-set values are not initialized here, use updateView.

    * @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to property names defined in the manifest, as well as utility functions.

    * @param notifyOutputChanged A callback method to alert the framework that the control has new outputs ready to be retrieved asynchronously.

    * @param state A piece of data that persists in one session for a single user. Can be set at any point in a controls life cycle by calling 'setControlState' in the Mode interface.

    * @param container If a control is marked control-type='standard', it will receive an empty div element within which it can render its content.

    */

       public init(    context: ComponentFramework.Context<IInputs>,

                       notifyOutputChanged: () => void,

                       state: ComponentFramework.Dictionary,

                       container: HTMLDivElement)

       {

           this.date = document.createElement("input");

           this.date.type = "date";

           this.date.className = "date";

           this.time = document.createElement("input");

           this.time.type = "time";

           this.time.className = "time";

           var dateTime = context.parameters.dateTime.raw;

           if (dateTime != null) {

               var dateOnly = this.padLeft(dateTime.getFullYear(), 4) + "-" + this.padLeft(dateTime.getMonth()+1, 2) + "-" + this.padLeft(dateTime.getDate(), 2);

               var timeOnly = this.padLeft(dateTime.getHours(), 2) + ":" + this.padLeft(dateTime.getMinutes(), 2);

               this.date.value = dateOnly;

               this.time.value = timeOnly;

           }

           this.notifyOutputChanged = notifyOutputChanged;

           // register onChange events and forward them to CDS

           this.date.addEventListener("change", () => {

               this.notifyOutputChanged();

           });

           this.time.addEventListener("change", () => {

               this.notifyOutputChanged();

           });

           // add fields to container (div)

           container.appendChild(this.date);

           container.appendChild(this.time);

    }

    /**

    * Called when any value in the property bag has changed. This includes field values, data-sets, global values such as container height and width, offline status, control metadata values such as label, visible, etc.

    * @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to names defined in the manifest, as well as utility functions

    */

    public updateView(context: ComponentFramework.Context<IInputs>): void

       {

           var dateTime = context.parameters.dateTime.raw;

           if (dateTime != null) {

               var dateOnly = this.padLeft(dateTime.getFullYear(), 4) + "-" + this.padLeft(dateTime.getMonth()+1, 2) + "-" + this.padLeft(dateTime.getDate(), 2);

               var timeOnly = this.padLeft(dateTime.getHours(), 2) + ":" + this.padLeft(dateTime.getMinutes(), 2);

               this.date.value = dateOnly;

               this.time.value = timeOnly;

           }

    }

    /**

    * It is called by the framework prior to a control receiving new data.

    * @returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as “bound” or “output”

    */

    public getOutputs(): IOutputs

       {

           if (this.date.valueAsDate != null && this.time.valueAsDate != null) {

               var dateTime = new Date(this.date.valueAsNumber + this.time.valueAsNumber);

               return {

                   dateTime: dateTime

               };

           } else {

               return { dateTime: undefined }

           }

    }

    /**

    * Called when the control is to be removed from the DOM tree. Controls should use this call for cleanup.

    * i.e. cancelling any pending remote calls, removing listeners, etc.

    */

    public destroy(): void

    {

    // Add code to cleanup control if necessary

       }

       /**

        * Helper function to pad strings

        *

        */

       public padLeft(input: Number, length: Number): String

       {

           var result = input.toString();

           var c = '0';

           while (result.length < length) result = c + result;

           return result;

       }

    }

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I built your control and I have exactly the same issue and it's not an issue in your code - it's an issue in harness (emulation). You can report your issue here - powerusers.microsoft.com/.../pa_component_framework

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 146 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 59

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans