Hello All,
I’m facing problem during my project simple task.
Here is my requirement-
I’m creating a Sandbox solution for SPO(uploading WSP).In that solution. I’m writing code to fetch data from list and bind my data to ListView(Control).But it is not working.I don’t know why but if I write code just to simply get my Web title in Sandbox solution using CSOM(managed code) it is not working fine.
And always display error of Full Trust.
I need your attention to this.
Please suggest me something!
Thanks!☺
Hi,
Can you Share the code you are using?
Here you have the code I use to get list data using CSOM on SPO and in versions of SP2013 without SP1 installed.
function custom_getListOnUrlName(listSiteUrl, listUrl, listName) { try {
var clientContext = new SP.ClientContext(listSiteUrl);
var oList = clientContext.get_web().getList(listUrl);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Title" Ascending="True"/></OrderBy></Query></View>');
var listItems = oList.getItems(camlQuery);
clientContext.load(listItems);
clientContext.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded),
Function.createDelegate(this, onQueryFailed));
} catch (err) {
try {
onQueryFailed(listName);
}
catch (err) {
console.log('Unable to get data from list');
}
}
}
function onQuerySucceeded(sender, args) {
parseItems();
}
function onQueryFailed(listSiteUrl, listName) {
try {
var clientContext = new SP.ClientContext(listSiteUrl);
var web = clientContext.get_web();
var list = web.get_lists();
var targetList = list.getByTitle(listName);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Title" Ascending="True"/></OrderBy></Query></View>');
var listItems = targetList.getItems(camlQuery);
clientContext.load(listItems);
clientContext.executeQueryAsync(onQuerySucceeded, onQueryFallBackFailed);
}
catch (err)
{
onQueryFallBackFailed();
}
}
function onQueryFallBackFailed(sender, args) {
console.log('Unable to get data from list');
}