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

Notifications

Announcements

Community site session details

Community site session details

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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard