How to retrieve items from Camlquery

How can I retrieve items from the date range below:

  • 2014-12-07 08:00 to 17:00

  • 2014-12-08 08:00 to 17:00

  • 2014-12-09 08:00 to 17:00

With my query right now I am receiving 2014-12-07 08:00 to 2014-09-17:00.

This also adds hours to my time:

  • var fromTime;
  • var toTime;
  • var listItemCustom;
  • var listItemtoDate;
  • var fromTimeConverted;
  • var toTimeConverted;

function checkFreebookingdateTime() {

getListCalender = document.getElementById('CalenderListDrop').value;
spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
context = new SP.ClientContext.get_current();
parentContext = new SP.AppContextSite(context, spHostUrl);
web = parentContext.get_web();
list = web.get_lists().getByTitle(getListCalender);

                var fromDate08 = "T08:00:00Z";
                var toDate17 = "T17:00:00Z";
                listItemCustom = document.getElementById('datepicker').value;
                var listItemFromTime = document.getElementById('timepicker').value;
                listItemtoDate = document.getElementById('datepickerto').value;
                var listItemToTime = document.getElementById('timepickerTo').value;
                var result = listItemCustom + "T" + listItemFromTime + ":00" + "Z";
                var result2 = listItemtoDate + "T" + listItemToTime + ":00" + "Z";
                fromTime = new Date(result);
                var numberToAddbefore = -1;
                fromTime.setDate(fromTime.getDate() + numberToAddbefore);

                fromTimeConverted = fromTime.toJSON().split('T')[0] + fromDate08;
                toTime = new Date(result2);
                var numberToAddafter = 1;
                toTime.setDate(toTime.getDate() + numberToAddafter);

                toTimeConverted = toTime.toJSON().split('T')[0] + toDate17;

                var camlQuery = new SP.CamlQuery('<View><Query><Where><And><Geq><FieldRef Name='EventDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'>' + fromTimeConverted + '</Value></Geq><Leq><FieldRef Name='EndDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'>' + toTimeConverted + '</Value></Leq></And></Where></Query></View>');

                collListItem = list.getItems(camlQuery);

                context.executeQueryAsync(onQuerySucceeded, onQueryFailed);


How to upgrade SharePoint app where the SharePoint app is installed on 20+ sites?

I understand stand the App upgrade process for a SharePoint hosted app and when I update my App Catalog for the web application I then can upgrade the app successfully manually for a site.

But my question is my site collection contains 20+ sites. Each site uses the app. In the past when using solutions I used a Site collection feature, updated the feature and all sites got the upgrade.

How can I have all 20+ sites update to the newer version without going through each site manually and updating it one site at a time?


Can't add app from SharePoint Store – “Attribute Prerequisite ID is missing.”

I’m trying to add an app from the SharePoint Store to my on-prem App Catalog site.

The app I want to add is grayed out and says

“You can’t add this app here”,

and when I click on it I get the error

“Attribute Prerequisite ID is missing.”

I’ve tried googling around to find out what this means exactly and how to fix it, but I can’t seem to find anything.

Anyone know what this means? (And how to fix it?)

How to deal with SP Apps when the SP farm is in a different AD domain?

I have a situation here where my laptop is on our “production” AD domain, and my SP2013 farm is in a “test” AD domain. I have a personal account in the test domain, and I have set up a generic SP Admin account in the test domain. (My personal account is also a farm admin and site collection admin.)

I have set up the app infrastructure correctly (app domain in DNS, etc.), and apps seem to work, but I was running into the issue of the app config page and app parts prompting for credentials. So I followed the advice I found online and added the app domain to my local Intranet sites in IE internet settings.

Now what’s happening is that the app parts and app configuration pages say

Sorry, this site hasn’t been shared with you.

I’m logging in to my laptop with my production domain credentials, but when I go to the SP site I’m logging in with my test domain credentials. If I take the app domain out of my Intranet sites, and force the second credential check, and use the test domain credentials, everything seems to work. So I’m guessing that what’s happening is that with the app domain in the Intranet sites, my production domain credentials are getting passed on to the app.

Am I right in my assumption? What’s a good way to deal with this? I’ve had previous experiences that led me to believe SP would use the credentials you logged in to the site with (in this case, my test domain account), which are associated with the browser session, and not default to the credentials you are logged in to the machine with.


In addition, it seems like anything opening from the app domain loses all the SharePoint bits. Here’s a screen shot of an app configuration page in a working environment:
enter image description here

And here’s a screen shot of the same app configuration page in my environment:
enter image description here

Anyone have any ideas as to why this might be happening?

SharePoint 2013 – App Development Environment

While trying to setup a App Development Environment for SharePoint 2013, am facing the issue the below.

I did not modify anything, it is just the default app package that VS2013 generates.

enter image description here

However, I could verify that app domain is properly configured.

enter image description here

Also, have configured the loop back adapter

enter image description here

App URLs are configured as below

enter image description here

Below are the list of web-application running on the Farm

enter image description here

Binding in IIS

enter image description here

Fiddler says

enter image description here

enter image description here

ULS Logs:

enter image description here

Cross Site Collection call in SP Hosted App

I want to read a list from one of my site collection(SiteColl A) using a SP Hosted App. This App will be deployed in another Site collection(SiteColl B) in the same web application. I know one way to achieve this is by using Tenant Scope Deployment and using AppContextSite object. But Tenant scope deployment will create only one App web below the App Catalog Site,which i do not want since it will be deployed in multiple site collections and each with different branding.(Will have to reconsider this if no other solution works out).

So i am trying to explore other techniques like REST call from the app to the other site collection (this is a public site with anonymous access). So i added a Script Editor webpart in my SiteCollB and tried to read list in SiteCollA using REST service call, and it worked perfectly and gave me the data. But that same code is somehow not working in the App.

      url: "http://sitecollectionURL/_api/web/lists/GetByTitle('CommonSettings')/items",
      type: "GET",
      headers: {
          "accept": "application/json;odata=verbose",
      success: function (data) {
          $.each(data.d.results, function (index, item) {
      error: function (error) {

So is the App masking its restriction on to my REST call? Is there any other technique to achieve this?

How to get the code of a default application

Can i get the source code of a default Sharepoint Application.

I want to retrieve the code of the application “Post” of a “Blog Site” on Sharepoint online because i need to modify it to change his design.

Is it possible? If so, how?

How to migrate existing lists into new sharepoint app?

I have sharepoint app in mind consisting of 2 lists, some automatic workflows, and some manually triggered workflows with corresponding ribbon buttons.

Right now client use site + lists + some automatic workflows.

How do I move existing data without disrupting workflows?

  • Workflows are quick, but I still need to know that non are pending when I start migrating data
  • I do not want to trigger automatic workflows for items that already had them executed.

How do I move data in bulk, and preferably automatically?

Should I just make my app as usual, and provide workflows for legacy lists, which site admin will execute as after-deployment step?

SharePoint CSOM C#: How to copy metadata [Taxonomy Fields] from one library item to item from another library

I am writing SharePoint provider hosted app with SharePoint online. I have two libraries “LibOne”and “LibTwo” SharePoint site. I am creating item in “LibTwo” which is based on “LibOne” item. I want to copy values of “LibOneItemOne” columns to “LibTwoItemTwo” columns. As this provider hosted app, I need to use SharePoint client side object model C#. Below is sample code I am using. This code is failing to copy managed metadata fields. Does anyone know how handle all types of fields or any other approach.

        string LsHostURL = Request["SPHostUrl"];
        string LsAccessToken = "";
        string LsLibItemOneFileId = Request["LibItemOneId"];
        string LsLibItemTwoId = Request["LibItemTwoId"];
        using (ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(LsHostURL, LsAccessToken))
            var libItemOneList = clientContext.Web.Lists.GetByTitle("LibOne").GetItemById(Convert.ToInt32(LsLibItemOneFileId));
            clientContext.Load(libItemOneList, x => x.FieldValuesForEdit);
            var libItemTwoListItem = clientContext.Web.Lists.GetByTitle("LibTwo").GetItemById(Convert.ToInt32(LsLibItemTwoId));
            clientContext.Load(libItemTwoListItem, x => x.ContentType);
            ContentType contentType = LibItemTwoListItem.ContentType;
            FieldCollection fieldColl = contentType.Fields;
            foreach (Field field in fieldColl)
                if (!field.ReadOnlyField && !field.Hidden && !field.Sealed && field.InternalName != "ContentType" && field.InternalName != "FileLeafRef")
                    if(libItemOneList.FieldValuesForEdit[field.InternalName] != null)


SharePoint-hosted app Query

I am trying to Query were the eventdate and eventend are.

var result = listItemCustom + " " + listItemFromTime;
    newItem.set_item('EventDate', result);
    var result2 = listItemtoDate + " " + listItemToTime;
 var camlQuery = new SP.CamlQuery('<View><Query><Where><Neq><FieldRef Name='EventDate'/><Value Type='Text'>' + result + '</Value></Neq><Neq><FieldRef Name='EndDate'/ /><Value Type='Text'>' + result2 + '</Value></Neq></Where></Query></View>');
    this.collListItem = targetList.getItems(camlQuery);

The Queries does nothing why? I want to make so the user cant add the same date and time to my list

Question and Answer is proudly powered by WordPress.
Theme "The Fundamentals of Graphic Design" by Arjuna
Icons by FamFamFam