@@ -181,18 +181,16 @@ export class Item extends SharePointQueryableShareableItem {
181181 * @param properties A plain object hash of values to update for the list
182182 * @param eTag Value used in the IF-Match header, by default "*"
183183 */
184- public update ( properties : TypedHash < any > , eTag = "*" ) : Promise < ItemUpdateResult > {
184+ public update ( properties : TypedHash < any > , eTag = "*" , listItemEntityTypeFullName : string = null ) : Promise < ItemUpdateResult > {
185185
186186 return new Promise < ItemUpdateResult > ( ( resolve , reject ) => {
187187
188188 const removeDependency = this . addBatchDependency ( ) ;
189189
190- const parentList = this . getParent ( SharePointQueryableInstance , this . parentUrl . substr ( 0 , this . parentUrl . lastIndexOf ( "/" ) ) ) ;
191-
192- parentList . select ( "ListItemEntityTypeFullName" ) . getAs < { ListItemEntityTypeFullName : string } > ( ) . then ( ( d ) => {
190+ return this . ensureListItemEntityTypeName ( listItemEntityTypeFullName ) . then ( listItemEntityType => {
193191
194192 const postBody = JSON . stringify ( Util . extend ( {
195- "__metadata" : { "type" : d . ListItemEntityTypeFullName } ,
193+ "__metadata" : { "type" : listItemEntityType } ,
196194 } , properties ) ) ;
197195
198196 removeDependency ( ) ;
@@ -265,6 +263,18 @@ export class Item extends SharePointQueryableShareableItem {
265263 body : JSON . stringify ( { "formValues" : formValues , bNewDocumentUpdate : newDocumentUpdate } ) ,
266264 } ) ;
267265 }
266+
267+ /**
268+ * Ensures we have the proper list item entity type name, either from the value provided or from the list
269+ *
270+ * @param candidatelistItemEntityTypeFullName The potential type name
271+ */
272+ private ensureListItemEntityTypeName ( candidatelistItemEntityTypeFullName : string ) : Promise < string > {
273+
274+ return candidatelistItemEntityTypeFullName ?
275+ Promise . resolve ( candidatelistItemEntityTypeFullName ) :
276+ this . getParent ( List , this . parentUrl . substr ( 0 , this . parentUrl . lastIndexOf ( "/" ) ) ) . getListItemEntityTypeFullName ( ) ;
277+ }
268278}
269279
270280export interface ItemAddResult {
0 commit comments