The StaticName and Name do not work on field creation
Closed this issue · 5 comments
Category
[ ] Enhancement
[x] Bug
[x] Question
Version
Version : 3.07
SharPoint Online (o365)
Expected / Desired Behavior / Question
Hi,
I have a problem to create a fields. The "StaticName" or "Name" for technical name do not work.
If I test this :
var fieldXML = "<Field DisplayName='My PnP TextField' Type='Text' Required='FALSE' StaticName='myPnpTecnicalName' />";
$pnp.sp.web.lists.getByTitle('my list').fields.createFieldAsXml(fieldXML).then(function(result) {
console.log(result);
});
The "DisplayName" is always used, never the "StaticName" or "Name" parameters. I can not differentiate the displayed name (DisplayName) from the technical name (StaticName or Name) It's normal ? I never had the problem in xml (declarative mode in visual studio (.wsp))
Thanks,
Richard
In new test, it's only DisplayName becomes the internal name
var fieldXML = "<Field Type='Text' Required='FALSE' StaticName='myPnpTecnicalName' Name='myPnpTecnicalName' DisplayName='My name to displayed' />";
$pnp.sp.web.lists.getByTitle('My List').fields.createFieldAsXml(fieldXML).then(function(result) {
console.log(result);
});
Hey guys,
It's not something which can be fixed in the library. Requests are transmitted to SP REST API without changes which could potentially introduce this issue. In other words, raw REST request will behave the same.
AFAIK, REST API ignores StaticName/Name in field schema XML when creating a field in a list directly. At the same time, the same schema will end up with what you expect when creating a site column.
What I would suggest here is create a field with display name equal to the desired InternalName, then send an update of the field name to the desired display name.
P.S.
Thank you for your interest in the sp-pnp-js library. We wanted to mention that this library is being deprecated in July 2018 in favor of the new scoped pnpjs libraries. You should begin transitioning your existing projects when possible or start new projects with the new libraries. Please see the transition guide for more details on migrating and be sure to let us know if you have any questions. Thanks
Hi,
OK, thanks for response. I'm always surprised by the Microsoft logical ^^
Going to close this as answered, please reopen if you need to continue the discussion.