Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Check If Field Already Exists In SharePoint 2013 List Using JSOM
WhatsApp
Gowtham Rajamanickam
7y
19.7
k
0
1
25
Blog
Steps
Open your Notepad.
Copy the code given below and paste it.
Name it like spvalidation.js
Add Content Editor Webpart in your page.
Add saved.js file into your Webpart properties.
<script>
$(document).ready(
function
()
{
var
checkFieldExist=checkFieldExists(
'Documents'
);
});
function
checkFieldExists(listTitle){
var
context =
new
SP.ClientContext.get_current();
var
web = context.get_web();
var
list = web.get_lists().getByTitle(listTitle);
var
listFields = list.get_fields();
context.load(listFields);
context.executeQueryAsync(printFieldNames,onError);
function
printFieldNames() {
var
e = listFields.getEnumerator();
var
fieldExist =
false
;
while
(e.moveNext()) {
var
field = e.get_current();
if
(field.get_title() ==
"myfieldname"
) {
fieldExist =
true
;
}
}
return
fieldExist;
}
function
onError(sender,args)
{
return
fieldExist;
console.log(args.get_message());
}
}
</script>
Conclusion
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.
SharePoint
SharePoint2013
JSOM
List
Up Next
How to Add Choices to Existing Choice Field Using CSOM in SharePoint 2013 Online
Ebook Download
View all
Getting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JS
Read by 4.9k people
Download Now!
Learn
View all
Membership not found