简体   繁体   中英

get custom fields from SharePoint list item

Using the beta SharePoint REST API (using Microsoft Graph ). Would like to get all items for a list, including the content of custom fields.

When I use https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}?expand=columns,items(expand=fields) I see (in my case):

  • columns containing 32 fields, including standard ones (eg ID , Title , Status ) and the custom ones (eg Next_action )
  • fields containing only the default (in my case 23) fields, including id [note it is lower case], Title and Status fields and -as expected- not the custom ones.

The documentation shows an example of getting specific columns . When I use https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/items?expand=fields(select=ID,Title,Status,Next_action)

Then I get an array with all items, and per item the object fields that only contains the property id .

So: the other standard fields ( Title , Status ) and the custom field Next_action do not show up.

How do I get the values for a list of standard and custom fields?


EDIT: more details about the lists that I have:

A couple of the lists are default ones that have been customized (I believe Tasks, Issues, Risks), others are completely custom (Decisions, Changes). The Tasks lists has versioning.
Some observations:

  • Decisions list has no missing fields (=no difference between columns and the actual fields )
  • all of them have "missing": ID|Author|Editor|DocIcon|AppAuthor|AppEditor, and fields that are not in the Columns: id|AuthorLookupId|EditorLookupId; both can be explained I guess (note that ID in column and id in field)
  • the missing fields are a variety of types: text (rich / plain, single / multi line), number, choice, etc.

Possibly related, when using Flow I create a trigger for "when an item is created or modified", I am then presented with only 2 lists (Changes and Decisions). Missing: Tasks, Risks, Issues.

Tasks

  • fields (19): "Title|Predecessors|Priority|Status|PercentComplete|AssignedTo|Body|StartDate|Checkmark|ContentType|Modified|Created|_UIVersionString|Attachments|Edit|LinkTitleNoMenu|LinkTitle|ItemChildCount|FolderChildCount"
  • missing (13): " DueDate|RelatedItems|JIRA_id|Progress_notes|Next_action|Waiting_for|Updates | ID|Author|Editor|DocIcon|AppAuthor|AppEditor "
  • fields not in Columns (4): " PercentComplete@odata.type | id|AuthorLookupId|EditorLookupId "

Risks

  • fields (22): "Title|Status|Category|DueDate|Probability|Impact|Exposure|Cost|Cost_x0020_Exposure|Description|Mitigation_x0020_plan|Trigger|ContentType|Modified|Created|_UIVersionString|Attachments|Edit|LinkTitle|ItemChildCount|FolderChildCount"
  • missing (12): " Owner|AssignedTo|Impact_x0020_description|Contingency_x0020_plan|Trigger_x0020_Description|RelatedItems | ID|Author|Editor|DocIcon|AppAuthor|AppEditor "
  • fields not in Columns (7): " OwnerLookupId|Probability@odata.type|Impact@odata.type|Cost@odata.type | id|AuthorLookupId|EditorLookupId "

Issues

  • fields (16): "ContentType|Title|Modified|Created|_UIVersionString|Attachments|Edit|LinkTitleNoMenu|LinkTitle|ItemChildCount|FolderChildCount|Status|Category|Priority|DueDate|Discussion"
  • missing (10): " ID|Author|Editor|DocIcon|AppAuthor|AppEditor | Owner|AssignedTo|Resolution|RelatedItems "
  • fields not in Columns (5): " id|AuthorLookupId|EditorLookupId | OwnerLookupId|AssignedToLookupId "

Decisions

  • fields (14): "Title|Description|Decided_by|Date_decided|ContentType|Modified|Created|_UIVersionString|Attachments|Edit|LinkTitleNoMenu|LinkTitle|ItemChildCount|FolderChildCount"
  • missing (6): " ID|Author|Editor|DocIcon|AppAuthor|AppEditor "
  • fields not in Columns (3): " id|AuthorLookupId|EditorLookupId "

Changes

  • fields (13): "Title|Status|Priority|ContentType|Modified|Created|_UIVersionString|Attachments|Edit|LinkTitleNoMenu|LinkTitle|ItemChildCount|FolderChildCount"
  • missing (14): " Description|Action|Background|Impact|Impact_x0020_delivery_x0020_time|Impact_effort|Impact_functionality|Impact_cost | ID|Author|Editor|DocIcon|AppAuthor|AppEditor "
  • fields not in Columns (3): " id|AuthorLookupId|EditorLookupId "

There seems to be a bug in the current /beta endpoint around $expand={field}($select={field}) . I'm seeing similar results.

I am however seeing the complete list of fields when I use:

/beta/sites/{site-id}/lists/{list-id}/items?$expand=fields

I'm also able to return the complete set of columns, items and fields using:

/beta/sites/{site-id}/lists/{list-id}$expand=columns,items($expand=fields)

For the time being, you'll need to pull the entire collection and handle any additional processing in your app. Being a beta release there are several bugs still being worked out. This is why it isn't recommended that this be used for production.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM