I'm creating a list instance in an XML file and I have some fields which are of type "Person or group". In the XML I can specify it like this:

<Row>
     <Field Name='ID'>100</Field>
     <Field Name='Title'>Foo Bar</Field>
     <Field Name='MyGroup'>66;#SomeOfMyGroups</Field>
     .....
</Row>
......

Notice the declaration of the group: 66;#SomeOfMyGroups.

When I do this it works, but I don't know what the ID of the group will be at some point.

If I specify it like this <Field Name='MyGroup'>SomeOfMyGroups</Field> it no longer works, the row is excluded when the list instance is created.

How can I set the value for the row without relying on the ID and just use the name (the name never changes, the ID might)?

有帮助吗?

解决方案

You can use a feature receiver for this, as described in the answer at: https://stackoverflow.com/questions/7091281/sharepoint-2010-adding-sample-data-to-user-field-type.

This way you can generate valid ID+Name sets for your rows.

许可以下: CC-BY-SA归因
scroll top