Question

I'm unable to set the default value to false of my boolean field called Done

pnp.sp.web.lists.add("Todo","").then(() => {
  pnp.sp.web.lists.getByTitle("Todo").fields.add("Done","SP.FieldText",{
    FieldTypeKind: 8,
    Hidden: false
  }).then(() => {

  });
});

Does anyone have an idea, because I can't find any documentation on this.

Was it helpful?

Solution

You can try setting the xml schema of the field:

pnp.sp.web.lists.getByTitle("Todo").fields.createFieldAsXml('<Field 
    Type="Boolean" 
    DisplayName="Done" 
    Required="FALSE" 
    Indexed="FALSE" 
    ID="{f1c6f202-f976-4f4e-b0a3-8b984991d00d}" 
    StaticName="Done" 
    Name="Done" >
<Default>false</Default>
</Field>').then(f => {
    console.log(f);
});
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top