Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 35 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Developer for General Motors, and also as a consultant.

I downloaded and installed the Windows 10 Technology Preview today because I was interested in seeing how it would behave on my Surface Pro. I started out creating a VMWare VM with the following hardware settings:Continue reading Windows 10 TP – First Look→

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 35 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Developer for General Motors, and also as a consultant.

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 35 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Developer for General Motors, and also as a consultant.

There are countless ways to read data from a SharePoint list, and also myriad methods to do this in JavaScript, but I’m going to document this one way as a place to get started, and a published function I can refer back to if needed!

First consider the following: Reading SharePoint list data using JavaScript requires the SP.js file to be loaded already. So, we should be putting this function inside of a $(document).ready(function())}; and if needed inside an ExecuteOrDelayUntilScriptLoaded(functionName, ‘sp.js’); Once in there, it would look something like this:

I’ll go over each line to explain what’s happening:var query = new SP.CamlQuery(); – this is preparing a CamlQuery object using SP.js (which is why it’s important to wait for it to be loaded!)query.set_viewXml – Here’s where you define your CAML query using normal CAML syntax. In the above scenario, it will return the Title field from all items in the list.var clientContext = SP.ClientContext.get_current(); – this establishes a client context object using the current Site Collection.var oList = clientContext.get_web().get_lists().getByTitle(‘List Name’); – this creates an object that references the specific list in the specific web you wanted to pull items from.var items = oList.getItems(query); – this is saying get the items from the list object based on the query defined above.clientContext.load(items); – you’re now telling the object model to prepare to execute the following object by loading it into the client context.clientContext.executeQueryAsync – ok, here you actually execute the query you so dutifully prepared just a moment ago. This operation expects a “Success” function and a “Failed” function to be passed in or referred to somehow. The success function will be what you want to do once the query is done executing. The failed function will be how you want to handle any issues.

What this is doing is looping through the results of the query and reading each one. The key is, to read a field value the syntax is listItem.get_item(‘Field Name’). Again, lots of ways to read field data, especially system fields like ID, this is just one example.

To handle errors I simply have whatever the error message is log to the console. At this point you can do what you like with the resulting data: put it in a string array and read it later, push it out to the page, make decisions based on the results, etc. Hope this helps!

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 35 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Developer for General Motors, and also as a consultant.

Just wanted to write this down so I don’t forget how to do this, if this helps someone else out even better!

If you’re wanting to access the Created By, Created On, Modified By and Modified on information on a custom list form in SharePoint 2010 or 2013, you can do this using the SharePoint:CreatedModifiedInfo control and use the CustomTemplate element, like so:

SharePoint uses the field names Author, Created, Editor and Modified to refer to the following:

Author: Created by
Created: Date Created
Editor: Modified by
Modified: Date last modified

You can include any combination of these fields and any other HTML/CSS to adjust the layout as needed either inside or outside of the CreatedModifiedInfo control. If you want to separate out the fields into separate areas of the page, you will need to repeat the control pattern of SharePoint:CreatedModifiedInfo->CustomTemplate->FormField for each section.

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 35 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Developer for General Motors, and also as a consultant.