Skip to main content

I am querying a list using JavaScript, from time to time the list items are retrieved, however, there are times that it returns an access denied error.

 

103371_pastedImage_15.png

 

var web = clientContext.get_web();

var list = clientContext.get_web().get_lists().getByTitle("Employee Hours Profile");

 

var camlQuery = new SP.CamlQuery();

camlQuery.set_viewXml('<View>' +

     '<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>xItemTitle]</Value></Eq></Where></Query>' +

          '<ViewFields>' +

               '<FieldRef Name='Title' />' +

          '</ViewFields>' +

     '<RowLimit>1</RowLimit>' +

'</View>');

 

var listItems = list.getItems(camlQuery);

 

clientContext.load(listItems);

clientContext.executeQueryAsync(onSuccess, onFail);

 

function onSuccess() {

     var listItemEnumerator = listItems.getEnumerator();

 

     while (listItemEnumerator.moveNext()) {

          var listItem = listItemEnumerator.get_current();

          var title = listItem.get_item('Title');

     }

 

     NWF$("#" + varTitle).val(title);

}

 

function onFail(sender, args) {

     alert("Error");

}

Hi Ricardo,

The JavaScript will be executed with the permissions of the current user opening the page. 

I would check permissions on the list to ensure the users seeing this issue have access to read the list.

Thanks,

Barry.


Unfortunately, "lookup" is not existing in the runtime functions in Forms for Office 365.

It depends on the need but you can use the List lookup action in "SharePoint" category and apply a filter ('Filtering' option). May be it will necessary to use JS to get the value displayed with the action.


Reply