Skip to content

Commit ccb4f1f

Browse files
authored
🤖 Merge PR DefinitelyTyped#72182 Add return type to Xrm.WebApi.updateRecord by @aquacash5
1 parent 880802c commit ccb4f1f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

‎types/xrm/index.d.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6083,7 +6083,7 @@ declare namespace Xrm {
60836083
* @returns On success, returns a promise object containing the attributes specified earlier in the description of the successCallback parameter.
60846084
* @see {@link https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-webapi/updaterecord External Link: updateRecord (Client API reference)}
60856085
*/
6086-
updateRecord(entityLogicalName: string, id: string, data: any): Async.PromiseLike<any>;
6086+
updateRecord(entityLogicalName: string, id: string, data: any): Async.PromiseLike<UpdateResponse>;
60876087
}
60886088

60896089
/**
@@ -6094,6 +6094,14 @@ declare namespace Xrm {
60946094
id: string;
60956095
}
60966096

6097+
/**
6098+
* Interface for the WebAPI UpdateRecord request response
6099+
*/
6100+
interface UpdateResponse {
6101+
entityType: string;
6102+
id: string;
6103+
}
6104+
60976105
/**
60986106
* Interface for the Promise error response arguments
60996107
*/

‎types/xrm/xrm-tests.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,16 @@ Xrm.Utility.getEntityMetadata("account", ["telephone1"]).then((metadata) => {
255255
console.log(metadata.Attributes["statuscode"].OptionSet[0].Label.LocalizedLabels[0].Label);
256256
});
257257

258+
// Demonstrate WebAPI CreateRecord
259+
Xrm.WebApi.createRecord("contact", { fullname: "Neo" }).then((response) => {
260+
console.log(response.entityType, response.id);
261+
});
262+
263+
// Demonstrate WebAPI UpdateRecord
264+
Xrm.WebApi.updateRecord("contact", "1d-123", { fullname: "Neo" }).then((response) => {
265+
console.log(response.entityType, response.id);
266+
});
267+
258268
// Demonstrate WebAPI RetrieveMultiple
259269
Xrm.WebApi.retrieveMultipleRecords(
260270
"contact",

0 commit comments

Comments
 (0)