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);
}
);
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
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);
WarrenBelz
87
Most Valuable Professional
mmbr1606
71
Super User 2025 Season 1
Michael E. Gernaey
65
Super User 2025 Season 1