cancel
Showing results for 
Search instead for 
Did you mean: 
rampprakash

PowerApps- Show or Hide TIME component from Date Time in Model Driven Apps

Implementation Steps:

 

Some time Use want to Show/Hide Time Field Component based on their Requirement

 

rampprakash_0-1635767054619.png

 

To Achieve that we need to write some JavaScript to enable and disabled Component

 

Syntax:

 

 

 

formContext.getControl(arg).setShowTime(bool);

 

 

 

arg = Field Logical Name

bool = true/false 

 

To Enable time Component:

 

 

 

function enableTimeComponent(executionContext){
var formContext = executionContext.getFormContext();
formContext.getControl("FieldLogicalName").setShowTime(true);
}

 

 

 

To Disable time Component:

 

 

 

function enableTimeComponent(executionContext){
var formContext = executionContext.getFormContext();
formContext.getControl("FieldLogicalName").setShowTime(false);
}

 

 

 

That's it 🙂

Comments

Hi @rampprakash , Where do I have to put/save this script for it to work?

Thanks

Hello @DanielAmico,

 

Please find my link for JS (Onload/Onsave/OnChange) Event, and hope this helps. Let me know if you need any help:

 

https://www.youtube.com/watch?v=x8kYNCkikgs&t=14s