purtuga / SPWidgets

Sharepoint Custom UI Widgets
74 stars 34 forks source link

File.ID parameter missing for some users #78

Closed princyphlp closed 6 years ago

princyphlp commented 6 years ago

Hi

Recently some users are experiencing issue where the file.ID parameter is returning empty after the Upload is done , I am pasting code snippet below, so after the file is uploaded , we update the file metadata using REST code [UpdateListItem(strURLSLDL, itemDL)], the REST url variable [strURLSLDL] is referencing file ID but apparently for some users the file.ID property is coming as 'undefined' and metadata will not be updated, any ideas why the File.ID coming as 'undefined'.

Appreciate help... Thanks

onUploadDone: function(file){//alert('3'); if(fileName == '') AfterUpload(file); else {
var strURLSLDL = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + libraryName + "')/items(" + file.ID + ")";

    var itemDL =  { "__metadata": { "type": libItemType}, "Key":keyVal, "Category":catFile, "YrQtr":fldYrQtr};

    UpdateListItem(strURLSLDL, itemDL);
}
purtuga commented 6 years ago

That's strange. once the user is past the "upload is done" stage, my code does a getListItems against the document library and retrieves the last file created by the user. Perhaps you can use the browser developer tools and look in the network tab to see if this API call is successful and that it returns the data expected?

Another thought: I just noticed the particular call to the list (getListItems) is done in synchronous mode - which may no longer be supported by by the browser... Do you know what browsers the users were using when this happen? I wonder if this is the issue.

princyphlp commented 6 years ago

Thanks for response We tried it with IE 8 and IE 11, not sure its browser issue, but as you have mentioned we think its latency that's causing issue , as it's happening for some users and behavior is very intermittent.

purtuga commented 6 years ago

Yeah, its hard to determine where the issue might be. If somehow you are able to capture it, look at the browser console and see if there are any errors. Also, from the developer tools network tab, you should see the call to the Doc. Library to get the newly created file.