Breeze - Get SharePoint AttachmentFiles from List using Expand? -


i using breeze sharepoint online list, support attachments. breeze query, correctly calls expand , can see through browser , fiddler, json returned attachment data in it. however, entities created in breeze javascript don't contain data attachmentfiles. null. sp adapter doesn't support, or defining attachmentfiles , list entities incorrectly. have tried numerous ways define relationship, using complextype , navigation, autogen id , without, coming stumped.

rest request looks this: /_api/web/lists/getbytitle('contacts')/items?$expand=author/id,attachmentfiles&$select=id,authorid,firstname,title,email,author,attachmentfiles ,author/username

attached view of json returned, , current breeze entities mapped.

snippet entities

    //attachments addtype({   name: 'attachmentfiles',   dataproperties: {     serverrelativeurl: {       nullable: false     },     filename: {       nullable: false     }    } });  // create entity contacts addtype({   name: 'contacts',   defaultresourcename: 'getbytitle(\'contacts\')/items',   dataproperties: {     id: {       type: breeze.datatype.int32     },     authorid: {       type: breeze.datatype.int32     },     firstname: {       nullable: false     },     title: {       nullable: false     }, // last name field in list     email: {       nullable: false,       validators: [breeze.validator.emailaddress()]     },     author: {       complextypename: "author"     }   },   // let model.validation add requirereferenceentity validators   navigationproperties: {     attachmentfiles: {       type: 'attachmentfiles',       hasmany: true     }   } }); 

see json response below

{ "d": {     "results": [         {             "__metadata": {                 "id": "388762a5-a565-4033-af90-5a2ea4cb1894",                 "uri": "https://foo-616175366e015f.sharepoint.com/sites/devsite/breezesp2013sample/_api/web/lists(guid'df211835-f6df-4bb0-b7f0-0995c6ff8562')/items(1)",                 "etag": "\"3\"",                 "type": "sp.data.contactslistitem"             },             "attachmentfiles": {                 "results": [                     {                         "__metadata": {                             "id": "https://foo-616175366e015f.sharepoint.com/sites/devsite/breezesp2013sample/_api/web/lists(guid'df211835-f6df-4bb0-b7f0-0995c6ff8562')/items(1)/attachmentfiles('8328787dc792224f625c9645a45d01aa.jpg')",                             "uri": "https://foo-616175366e015f.sharepoint.com/sites/devsite/breezesp2013sample/_api/web/lists(guid'df211835-f6df-4bb0-b7f0-0995c6ff8562')/items(1)/attachmentfiles('8328787dc792224f625c9645a45d01aa.jpg')",                             "type": "sp.attachment"                         },                         "filename": "8328787dc792224f625c9645a45d01aa.jpg",                         "serverrelativeurl": "/sites/devsite/breezesp2013sample/lists/contacts/attachments/1/8328787dc792224f625c9645a45d01aa.jpg"                     },                     {                         "__metadata": {                             "id": "https://foo-616175366e015f.sharepoint.com/sites/devsite/breezesp2013sample/_api/web/lists(guid'df211835-f6df-4bb0-b7f0-0995c6ff8562')/items(1)/attachmentfiles('screen shot 2015-04-23 @ 10.28.35 am.png')",                             "uri": "https://foo-616175366e015f.sharepoint.com/sites/devsite/breezesp2013sample/_api/web/lists(guid'df211835-f6df-4bb0-b7f0-0995c6ff8562')/items(1)/attachmentfiles('screen%20shot%202015-04-23%20at%2010.28.35%20am.png')",                             "type": "sp.attachment"                         },                         "filename": "screen shot 2015-04-23 @ 10.28.35 am.png",                         "serverrelativeurl": "/sites/devsite/breezesp2013sample/lists/contacts/attachments/1/screen shot 2015-04-23 @ 10.28.35 am.png"                     }                 ]             },             "author": {                 "__metadata": {                     "id": "1fdc1547-d439-42bd-b3aa-b41e92c8ec6f",                     "type": "sp.data.userinfoitem"                 },                 "username": "user@contoso.com"             },             "id": 1,             "id": 1,             "title": "alanso",             "authorid": 1073741823,             "firstname": "fernando",             "email": "fernando.alonso@ferrari.it"         }     ] } 

}

i see problems here ... can cure.

first, i'd call attention "debugging query results" documentation has many tips diagnose what's going on. not of them applicable valuable clues in there.

i'm curious if entitymanager has entities of type "attachmentfiles". rather doubt it. might check.

regardless, 2 observations leap out @ me:

  1. the attachmentfiles type not have key property, property uniquely identifies instance of type. every entitytype must have @ least 1 key property. metadatahelper can detect keys convention there no obvious candidate in attachmentfiles. if there 1 (and don't see it), you'll have specify it.

i'm assuming you're using metadatahelper defined in breeze labs breeze.metadata-helper.js write metadata rather raw breeze api purpose. looks doing ... , that's thing.

  1. your contacts type identifies one-to-many navigation attachmentfiles doesn't specify foreign key relationship in attachmentfiles link instances of attachmentfiles contacts. if breeze created attachmentfiles instances json payload, not associate them instances of contacts

i don't see in data supports notion attachmentfiles entities. seem embedded in contact type.

there way represent that. i'd want confirmation before went down road. maybe can clarify of points raised here before propose next steps.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -