SharePoint 2013 supports API methods given below to perform basic operations like Create, Update, Read and Delete.
- Server Side Object Model (SSOM).
- Client Object Model (CSOM).
- JavaScript Object Model (JSOM).
- REST.
Steps
- Open your Notepad.
- Copy the code given below and paste it.
- Name it as spvalidation.js.
- Add Content Editor Webpart in your page.
- Add saved .js file into your Webpart properties.
Code
- <script>
- $(document).ready(function()
- {
-
- var checkFieldExist=checkFieldExists();
- });
-
- function checkFieldExists(){
-
- var ctx = SP.ClientContext.get_current();
-
- var folder = ctx.get_web().getFolderByServerRelativeUrl("/path/to/folder");
-
- ctx.load(folder, "Exists", "Name");
-
- ctx.executeQueryAsync(
- function() {
- if (folder.get_exists()) {
-
- console.log(folder.get_name());
- }
- else {
- console.log("Folder exists but is hidden (security-trimmed) for us.");
- }
- },
- function(s, args) {
- if (args.get_errorTypeName() === "System.IO.FileNotFoundException") {
-
- console.log("Folder does not exist.");
- }
- else {
-
- console.log("Error: " + args.get_message());
- }
- }
- );
-
- }
- </script>
Was my blog helpful? If yes, please let me know and if not, please explain what was confusing or missing.
I’ll use your feedback to double-check the facts, add info and update this blog.