How can I call a Jscript function from XML, which is written seperatly outside the xml file

Dear All,

I have made a SharePoint ribbon button which should display an alert message with SharePoint custom list
ID information. But it has problem for calling the Jscript methods, It may be a XML tag mistake!!! Unable to
find the error in code line!!!, can somebody please tell me this error by referring my code snippet????

It is a farm SharePoint solution I have kept the Jscript file in mapped folder named "Layouts"

It  is showing the error as : JavaScript runtime error: The value of the property 'myFunction' is null or undefined, not a Function object

That means, as I understand the control is not moving or not calling the function from JScript file....why it
is so...not able to debug JScript or xml using Visual Studio that makes my effort tedious!!!

Code:

Elements.xml
------------

<CommandUIHandlers> 
       
<CommandUIHandler Command="ShowAlert"  CommandAction="javascript:retrieveListItems()"  EnabledScript="return true;"/>                 
      
</CommandUIHandlers>




 <CustomAction Id="Ribbon.Library.Actions.Scripts"  Location ="ScriptLink" ScriptSrc="/_layouts/RibAlert.js"/>
</Elements>

RibAlert.js
-------------

<script>


    var siteUrl = http://A5-1224';

function retrieveListItems()
{
    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('Measurements');  //getByTitle('Custom List');
    var camlQuery = new SP.CamlQuery();

    camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' +
    '<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');

    this.collListItem = oList.getItems(camlQuery);
    clientContext.load(collListItem);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}



</script>



February 21st, 2014 6:10am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics