Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
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);
	}
);

 

 

 

 

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: Updating datetime with WebApi offline

    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

     

     

  • Verified answer
    cchannon Profile Picture
    4,702 Super User 2025 Season 1 on at
    Re: Updating datetime with WebApi offline

    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) 

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 87 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 65 Super User 2025 Season 1

Overall leaderboard