Yes/No Field Default value problem!
-
02-10-2020 - |
Frage
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?
Lösung
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();
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange