Thank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your
needs please complete the below template to ensure we have the details to help. Thanks!
Please check out the Docs to see if your question is already addressed there. This will help us ensure our documentation covers the most frequent questions.
Please specify what version of the library you are using: [ 1.3.5 ]
Please specify what version(s) of SharePoint you are targeting: [ online ]
If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.
I'd like to get field descriptions of a Sharepoint list for a specific language. I've got the below sample code and am wondering how this can somehow been done with pnpjs.
Is #557 a starting point? And if so how to construct the xml query?
function retrieveWebSite(siteUrl) {
var clientContext = new SP.ClientContext(siteUrl);
this.oWebsite = clientContext.get_web();
this.oTitleResources = clientContext.get_web().get_titleResource();
this.valueEN = this.oTitleResources.getValueForUICulture("en-us");
this.valueDE = this.oTitleResources.getValueForUICulture("de-de");
clientContext.load(this.oWebsite);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
function onQuerySucceeded(sender, args) {
console.log('Title: ' + this.oWebsite.get_title() + ' | Description: ' + this.oWebsite.get_description());
console.log(this.valueEN.m_value);
console.log(this.valueDE.m_value);
}
function onQueryFailed(sender, args) {
console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
retrieveWebSite("https://contoso.sharepoint.com/sites/mysite");
If you are reporting an issue please describe the expected behavior. If you are suggesting an enhancement please
describe thoroughly the enhancement, how it can be achieved, and expected benefit. If you are asking a question, ask away!
If you are reporting an issue please describe the behavior you expected to occur when performing the action. If you are making a
suggestion or asking a question delete this section.
If you are reporting an issue please describe the steps to reproduce the bug in sufficient detail to allow testing. If you are making
a suggestion or asking a question delete this section.
It looks like there are a few places that expose these resource properties, and the good news is GetValueForUICulture is client callable. Will look at adding support for this.
Thanks, that would be great. The other day I found I can request a TitleResource or DescriptionResourcewith .select('DescriptionResource') and .expand('DescriptionResource') but then I couldn't figure out how to call GetValueForUICulture or how to expand the resource. Maybe that is the wrong way?
No, that won't work - we need to extend our model, working on that now.
All set, will be in 2.0.4. Thanks for the suggestion!
Thank you very much, highly appreciated. With this I will be able to implement what I want. But it will be a while as I am not allowed to work right now.
Though I won't be needing it I just want to mention that there is also a corresponding setter.
The setter doesn't work through REST, tried it but it relies on the CSOM context batched requests with execute. Some of the older APIs still work that way, and I wouldn't expect any updates for them any time soon.
Ok. Incidentally, can several GetValueForUICulture requests be combined in some sort of batch requests? I will be needing it for several fields and am worried about the number of requests this will result in.
It should work with our normal batching.
const batch = sp.web.createBatch();
sp.web.inBatch(batch).titleResource("en-us").then(r => console.log(`title: ${r}`));
sp.web.inBatch(batch).descriptionResource("en-us").then(r => console.log(`description: ${r}`));
await batch.execute();