On prem CRM 2015, I want to add a date and time field on the form customized entity, where a user can/should have an option to choose either 12 hours or 24 hours time format. later based on selection the time on the field should changed. I'm not having user behavioral option, as it's not an updated version.
*This post is locked for comments
Hi Salahuddin,
Date and time field is controlled by personal settings or system settings, so your requirement could be achieved by changing current user settings: the method I gave out is based on that we can change Current Format to different countries In Set Personal Options dialog, in English(US) format, the time is 12 hour format while in Italian(Italy), it's 24h.
My core logic is below,
// localeid: 1033 -> USA, 1040 -> Italy
var entity = {};
entity.LocaleId = 1033;
var userid = Xrm.Page.context.getUserId().replace("{", "").replace("}", "");
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/UserSettingsSet(guid\'"+ userid +"\')", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("X-HTTP-Method", "MERGE");
req.onreadystatechange = function() {
if (this.readyState === 4) {
this.onreadystatechange = null;
if (this.status === 204 || this.status === 1223) {
// Perform your success action
} else {
alert(this.statusText);
}
}
};
req.send(JSON.stringify(entity));
I send a PATCH Ajax request to update current user format settings.
You could find supported methods and writable attributes for updating user's settings in this official doc:
Note:
If you're not familiar with JavaScript and how to work with web resource, i'm glad to give more steps.
Best Regards,
Leo
Following thread might help you
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156