string benefitsLongDesc = web.Fields.Add("Benefits Long Description", SPFieldType.Note, false); web.Update(); SPField benefitsLongDescField = web.Fields[benefitsLongDesc]; benefitsLongDescField.Title = "Long Description"; benefitsLongDescField.Group = "Human Resources"; benefitsLongDescField.Update();
To resolve this, you have a couple of options:
- Don’t use spaces in the Display Name in code line 1, which is preferred as you don’t want your field internal name to contain spaces that get converted to _x0020_ and make your life miserable trying to remember to add those characters every time you want to call the field.
- In code line 3, instead of getting the field from web.Fields directly, use the following:
SPField benefitsLongDescField = web.Fields.GetFieldByInternalName(benefitsLongDesc);
Happy coding!
0 comments:
Post a Comment