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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Updating datetime with...
Power Apps
Answered

Updating datetime with WebApi offline

(0) ShareShare
ReportReport
Posted on by 2

I'm using Xrm.WebApi.offline.updateRecord to update a Dynamics record offline in my PCF component (as documented here: https://docs.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-webapi/updaterecord).

 

Other fields update smoothly offline, but if I add a datetime field to the mix & try to save, I get an uninformative error "An error has occurred...". I have tried several formats for the datetime with no success. What kind of date format is expected here?

 

 

 

let data: any = {};

data["myDateField"] = "dd/MM/yyyy hh:mm AM/PM";

Xrm.WebApi.offline.updateRecord("myentity", recordId, data).then(
	function success(result) {
		console.log("Entry updated.");
	},
	function (error) {
		console.log(error.message);
	}
);

 

 

 

 

I have the same question (0)
  • Verified answer
    cchannon Profile Picture
    4,702 Moderator on at

    You're trying to insert a string into that col, not a datetime. You have to actually construct the datetime value with new Date():

    let myDate = new Date("01/01/2022");

    or:

    let myDate = new Date(2022,01,01,0,0,0,0);

    JavaScript Date Objects (w3schools.com) 

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @LostInDynamics , 

     

    If was surely not the cause for your issue, but just wanted to add that using the Xrm.* object inside a PCF is not supported, 

    The right way would be to use the context.WebAPI, offered by the PCF sdk. That will automatically switch between online and offline if needed: https://docs.microsoft.com/en-us/power-apps/developer/component-framework/reference/webapi?WT.mc_id=BA-MVP-5004107

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard