Posted onWord count in article: 391Reading time ≈1 mins.
I opened a git repo by VS Code, but it shows No source control providers registered. One possible reason is that VS Code couldn’t find the executable git command, so we can set the executable path of git in settings. Open File -> Preferences -> Settings, then find the Git: Path setting, click Edit in settings.json, and add "git.path": "full-path-to-git" to settings.json.
Posted onWord count in article: 592Reading time ≈1 mins.
I ran into an error when running Remote - SSH in Visual Studio Code on Windows. The error shows that an SSH installation couldn’t be found, but I’ve installed the git client. Finally I found some useful info in the doc:
VS Code will look for the ssh command in the PATH. Failing that, on Windows it will attempt to find ssh.exe in the default Git for Windows install path. You can also specifically tell VS Code where to find the SSH client by adding the remote.SSH.path property to settings.json.
My git client was not installed in the default path, thus VS Code couldn’t find the ssh command. So I added the remote.SSH.path property to settings.json and problem solved.
Posted onWord count in article: 415Reading time ≈1 mins.
I tried to resize a Client Web Part with non integers as size, but it failed. And that’s why:
1 2 3 4
var regex = RegExp(/(<\s*[Mm]essage\s+[Ss]ender[Ii]d\s*=\s*([\dAaBbCcDdEdFf]{8})(\d{1,3})\s*>[Rr]esize\s*\(\s*(\s*(\d*)\s*([^,\)\s\d]*)\s*,\s*(\d*)\s*([^,\)\s\d]*))?\s*\)\s*<\/\s*[Mm]essage\s*>)/); var results = regex.exec(e.data); if (results == null) return;
The regular expression shows that it doesn’t allow float numbers.
Posted onWord count in article: 1kReading time ≈2 mins.
I’m learning how to upgrade SharePoint App, and I met a problem when I added a new list field in the upgrade.
The document mentioned that if you added a field to a content type in the feature, you should add an AddContentTypeField element to the VersionRange section. But there is no ContentType in my app, it only has a ListDefinition. I tried to add an AddContentTypeField, unfortunately it throws exception.
So I tried another way. The document also mentioned that if you have changed a file that is referenced in an elements manifest file, you have to copy the ElementManifest element for the component from the ElementManifests section to the ApplyElementManifests section. When we added a new field to list, the Schema.xml is changed, although it’s not referenced in a ElementManifest, I still copied MyList/Elements.xml to ApplyElementManifests, so it looks like this:
It tries to find the title element and resize it. But document.getElementById(webPartDivId + '_ChromeTitle') returns null if Chrome Type is None or Border Only!
Because the app part doesn’t have a title under these 2 modes. Of course it will throw exception.
Solution
This bug is described here, you can install a patch to fix this bug.
After the patch is installed, you can find that the original code is changed, it will resize the element only if it’s not null:
1 2 3 4 5 6 7 8 9 10
if (resizeWidth) { var webPartChromeTitle = document.getElementById(webPartDivId + '_ChromeTitle'); if (null != webPartChromeTitle) { webPartChromeTitle.style.cssText = widthCssText; }
Posted onWord count in article: 3.2kReading time ≈5 mins.
Introduction
SharePoint App Model provides a new approach to SharePoint development. And here is the question: where to save app data? There are several ways to save data in an app, you can create a list or connect to a database in Windows Azure or set custom properties in AppManifest.xml. But we can also save data to the property bag of a SharePoint web.
Add property to web
Adding custom property to web is easy. Let’s just see the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
var context = SP.ClientContext.get_current(); var web = context.get_web();
// Add a new property var props = web.get_allProperties(); props.set_item("MyProperty", "My property value");
// Apply change to web web.update(); context.load(web);
How do we know “MyProperty” is really added to web? We can check it here: http://your_web/_api/web/AllProperties?$select=MyProperty. The result looks like this: