Solved

SP2013: Rendering template and SCOM

Posted on 2014-02-12
2
391 Views
Last Modified: 2014-02-21
I have  a rendering template which contains SCOM code to delete list item. Nothing fancy.

            var clientContext = new SP.ClientContext("XXXXURL");
            var oList = clientContext.get_web().get_lists().getByTitle('XXXLIST');
            var oListItem = oList.getItemById(FROMVARIABLE);

            oListItem.deleteObject();
            clientContext.executeQueryAsync( ...

Open in new window


Problem. SharePoint deletes target list items but gives me an error: "Error: Unable to get property 'apply' of undefined or null reference" (ScriptResource.axd). I am not able to figure out what I am missing.  Seems like like I need need to include spjavascriptX. Any help would be appreciated.
0
Comment
Question by:tolppa
2 Comments
 
LVL 25

Accepted Solution

by:
devic earned 500 total points
ID: 39854046
I'm not familiar with  SP/SCOM, but one common mistake is, if someone is trying to access some element, that not exists yet.

maybe you can move your code to the end, just before </body>

maybe you need run this code after page loaded or something already added.


try check step by step.

var clientContext = new SP.ClientContext("XXXXURL");
console.debug('clientContext :' + clientContext );

var oList = clientContext.get_web().get_lists().getByTitle('XXXLIST');
console.debug('oList: ' + oList );

var oListItem = oList.getItemById(FROMVARIABLE);
console.debug('FROMVARIABLE:' + FROMVARIABLE);

Open in new window

0
 
LVL 1

Author Closing Comment

by:tolppa
ID: 39876592
I were able to fix my problem when I replaced clientContext.executeQueryAsync(onQuerySucceeded) ... with clientContext.executeQueryAsync(function () { //CODE.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now