**Uncaught TypeError: Cannot read property ‘get_current’ of undefined**
var ctx = new SP.ClientContext.get_current(); //**<--ERROR HERE** var cList = ctx.get_web().get_lists().getByTitle('2018Survey'); var itemCreateInfo = new SP.ListItemCreationInformation(); var listItem = cList.addItem(itemCreateInfo); listItem.set_item('CurrentSharePointRole', this._qs("#CurrentSharePointRole").value); listItem.set_item('SharePointYammerUseful', this._qs("#SharePointYammerUseful").value); listItem.set_item('SharePointYammerUsefulWHY', (this._qs("#SharePointYammerUsefulWHY").value) ? this._qs("#SharePointYammerUsefulWHY").value : "N/A"); listItem.set_item('AttendedBrownBag', this._qs("#AttendedBrownBag").value);
The site that I moved my code to was heavily customized and it was a publishing site. I’m not sure if it was the customization or the publishing feature that made my JSOM code to break but after much digging and debugging, I added the following libraries to my html and it worked perfectly.
I hope this helps someone. Thanks and please leave a comment if you find this helpful or insightful. Also, you are welcome to provide any feedback. I can take it. 🙂