0

I am trying to put a default user into a People or Group data type into a SharePoint Online list. Is this possible using CSOM or the XML definition?

This is what i have tried: -

XML

    <Field DisplayName="People" Name="theField" StaticName="theField" Type="User" UserSelectionMode="PeopleOnly" 
           ID="{63FD2388-BA5E-4BE4-B2BE-9406B02FD7D3}" Required="FALSE" Group="Group">
      <Default>1;#Joe Bloggs</Default>
    </Field>

CSOM

Microsoft.SharePoint.Client.User usr = clientContext.Web.EnsureUser(@"JoeBloggs");
clientContext.Load(usr);
clientContext.ExecuteQuery();

FieldUserValue defValue = new FieldUserValue();
defValue.LookupId = usr.Id;

theField.DefaultValue = defValue.ToString();
theField.Update();

Both tests make the field do thisenter image description here

Is this possible?

Thanks

1

Default values for People fields are not possible, either programmatically or via the UI.

You could fake the effect via a Remote Event Receiver, Webhook, or possibly a Flow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.