Hide the date part on a DateTime field - dynamics-crm

I would like to have a time-only field on my CRM form. As it is apparently not possible, I plan to use a DateTime field and hide the date part (circled in red on the following image).
How can I hide the date part on a DateTime field using Javascript ?

Found it:
// Set the date in order to be able to modify the time
document.getElementById("field_name").DataValue = new Date(2000, 1, 1);
// Hide the date part
document.getElementById("field_name").childNodes[0].childNodes[0].style.display =
"none";
document.getElementById("field_name").childNodes[0].childNodes[1].style.display =
"none";

Related

Rendering database UTC timestamp as local with Telerik controls

We're using the Telerik (PHP UI) controls but there appears to be something that I'm not able to crack.
We store timestamps in the backend database in UTC, and when using a Grid to display such items, I want to be able to show that UTC timestamp converted into the local users timezone (the TZ data is stored as a PHP variable, different people logging in could be in different TZs). It appears I'm not the only one that's asking this, as the Telerik forum someone else asks the same question but without an answer (scroll to the bottom of that forum post).
From the Telerik site I it appears that all I'd have to do is to format the date with a format with "zzz" appended to the date, but all this does is add the offset to the displayed time (eg 2020-02-27 10:00:00 -> 2020-02-27 10:00:00-0800) ... but it does do this "auto-magically" which I suppose is nice ... (heavy sarcasm)
This forum post also shows that an onRequestEnd call should do what I need it to do, but when I attempt this, nothing appears to change.
Can anyone offer up any advice?
Note : I've created the outer table with the following:
$grid = new \Kendo\UI\Grid('grid');
Solution: I achieved this by adding the following to the page:
function dataSource_requestEnd(e){
var data = e.sender.options.data.data;
for(var i=0; i<data.length; i++){
var td = data[i];
for (var key in td){
if (key === "NameOfDateField"){
var offset = new Date().getTimezoneOffset();
new Date(td[key].setMinutes(td[key].getMinutes() - offset));
}
}
}
}
$(document).ready(function() {
var dataSource = $("#grid").data("kendoGrid").dataSource;
dataSource.bind("requestEnd", dataSource_requestEnd);
dataSource.fetch();
});
Please note that NameOfDateField was the name of the key in the array that was returned from the dataSource.
TBH, I'm not at all sure how the data got converted, but certainly the offset and localTime variables are vital to this succeeding (although to my mind, they don't actually update anything?!)

How to display in a form/tree view a computed field with store = False ?Odoo 11

In Odoo 11, How to display in a form/tree view a computed field with store = False ?
For example :
The field Marge is a computed field with store=False
margin_pct = fields.Char(string = 'Marge', compute =
_getmarginpct)
When the view is in modify mode the value of the field marge is displayed and modified as well
modify image
But when the view is in save mode or when we come back on the view the value of the field marge is not displayed
save image
Thanks for your answers.
You must be modifying the value of margin_pct field in an onchange function. Since this field is read only the values modified by on change functions will not be saved. So use depends instead of onchange and it should work.

Zoho Creator -- Get calendar date from calendar report and paste into another form

I have a calendar report. when i click on a date, i want a different form to open, not the form that the calendar report is based on. Then i want the date value from the first form to be passed to the second form. So far, I have this code, on load of the Calendar Form:
MyDate = input.Departure_Date_Time;
//return same window to calendar report
openUrl("https://app.zohocreator.com/ccimailzoho/interhof-travel-
calendar#Calendar","same window");
//open trip form in popup
openurl("#Form:Trip_Form","popup window");
//Trip_Form.Departure_Date_Time = MyDate;
But it doesn't work; MyDate variable does not hold the value between the two forms. Any ideas?
For future viewers, if you want to set a value of a form on open from a different form, you can set the value directly in the openurl statement:openurl("#Form:Trip_Form?Departure_Date_Time=" + input.Departure_Time + "&Arrival_Date_Time=" + input.Departure_Time,"same window");

Is there a way to set the view on the kendo datepicker

I'm using the date picker to allow a user to select start and end dates.
When the page first loads, both date pickers will display the current month the first time the calendar is opened.
However, I want the start datepicker to open up a view from one year in the past.
I've looked through the api (options and methods) and haven't found anything to specify a month.
Has anybody tried this?
I don't quite get what view means. Just shooting in the dark - if you want to limit the start to 1 year in the past or on certain month in the past, there is a configuration option min.
From the Kendo examples:
<input id="datepicker" />
<script>
$("#datepicker").kendoDatePicker({
min: new Date(2011, 0, 1) // sets min date to Jan 1st, 2011
});
</script>
Update:
var datepicker = $("#datepicker").data("kendoDatePicker");
var d = new Date ();
$("#datepicker").kendoDatePicker({
value: new Date (d.setFullYear(d.getFullYear() - 1))
});
So this should open the "view" at this day 1 year ago. Live at the Dojo
There is a property called dateView that can have the value set.
Dojo Demo
var datepicker = $("#datepicker").data("kendoDatePicker");
datepicker.bind('open', function() {
if (this.value() !== this.dateView.value()) {
this.dateView.value(null);
}
});
datepicker.dateView.value(dt);
This will update the value in the popup calendar without updating the value of the widget itself.
Edit: This actually causes a bug where clicking the selected dateView value doesn't update the actual picker value. I've added a handler for the open event to take care of the mismatch and clear the selected dateView value.

kendo datepicker - set date without looking maxdate

I have one kind of scenario using date picker. I have date picker with max date=current date + 10 days,on page load only i want to show date more than the max date,but I'm allowing user to enter only up to max date. Is it possible. Without looking maxing date i want to display only the date what ever i want.code:-
var datepicker = $("#date" + uid).data("kendoDatePicker");
var addDays = new Date();
if (arr[1] == "") {
var d = new Date();
datepicker.min(new Date());
datepicker.max(new Date(d.getDate() , d.getMonth(), d.getDate()+ parseInt(arr[1]) - parseInt(1)));
}
I don't know if this is achievable. But what if you try to add two date pickers instead? One that display only the text, and the other only the calendar button. You need to play a bit the CSS, but I think it could spare you a lot of time.

Resources