Skip to content

Commit 460d1ef

Browse files
committed
Add GetObjIDByGUID method to retrieve Object ID by GUID
1 parent e78b60c commit 460d1ef

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/controllers/objectOperations.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,29 @@ CtrlDocs.ObjectOperations = class ObjectOperations {
5050
});
5151
}
5252

53+
/**
54+
* Get the Object ID by its GUID
55+
* @param {string} guid
56+
* @returns {Promise<CtrlDocs.ObjID>}
57+
*/
58+
GetObjIDByGUID(guid) {
59+
const errorMessage = `Get ObjID By GUID Failed`;
60+
61+
return new Promise((resolve, reject) => {
62+
if (CtrlDocs.Platform.IsNextGen()) {
63+
this.#native.GetObjIDByGUID(guid)
64+
.then(objID => resolve(new CtrlDocs.ObjID(objID.obj_id)))
65+
.catch(errorObj => reject(CtrlDocs.MFilesError.GetVnextErrorHandler(errorMessage)(errorObj)))
66+
}
67+
else this.#nativeAsync.GetObjIDByGUID(guid,
68+
(objID) => resolve(new CtrlDocs.ObjID(objID)),
69+
(short, long, obj) => reject(CtrlDocs.MFilesError.GetLegacyAsyncErrorHandler(errorMessage)(short, long, obj)),
70+
function () {}
71+
);
72+
});
73+
}
74+
75+
5376
/**
5477
* @param objID {CtrlDocs.ObjID}
5578
* @param allowCheckedOut {boolean}

0 commit comments

Comments
 (0)