Pergunta

I have tried following script to set default value of Yes/No Field to Yes which is by default set to No in list Yes/No column, i get false result at last line.

I have tried these values: 1 , $true, "1", Yes and "Yes" at line 1, but nothing works

 $item.Fields["My YesNo Field"].DefaultValue = "Yes" //Line 1
    $item.Fields["My YesNo Field"].Update()
    Write-host $item["My YesNo Field"].ToString()

Any idea to fix?

Foi útil?

Solução

Changing the first line to:

$item.Fields["My YesNo Field"].DefaultValue = "1"

should work.

I can confirm that the following code works in SOM:

SPList list = site.Lists["YesNo"];
list.Fields["My YesNo Field"].DefaultValue = "1";
list.Fields["My YesNo Field"].Update();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top