how to create a list template in SharePoint online using VS 2013 - development-environment

I am going to create some declarative items in SPO using VS. I know how to create it through UI by I want to create programmatically. As I did some research, there are 3 ways.
First is through SP hosted App(add-in) then give manage permission on host web to create some list on its parent site.
Here is the article:http://www.sharepointnadeem.com/2013/12/sharepoint-2013-apps-access-data-in.html
This approach is not good because App web shouldn't apply any change on its host web.
Second is through Sandbox solution. Once I try to create a sandbox solution using SPO site URL, I will receive an error which said connecting to a remote site is not possible through VS. So I have to enter a local SP URL to create a sandbox solution. then I should create list template declaratively and deploy it and publish it to my SPO environment. Here is the article which explain steps:http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/01/10/how-to-use-visual-studio-11-to-publish-solutions-to-sharepoint-online.aspx
The problem that I have with this approach is I don't have access to my managed metadata columns which are located in SPO once I am developing list template in my local development machine.
Third approach is creating List or content type or template in App web which is not my case. This has been explained in this article:
sharepoint-journey.com/sharepoint-list-in-sharepoint-hosted-app.html
The problem here is, I want to have that template in my site (host site) not in App web site (sub site)
My question is: I want to provide some list template in my SPO environment by using VS 2013. what is the best approach for doing that? and how can I do that? Please give me an step by step instruction.
Thank you

You definetly want to go the App(Add-in) way. It is possible and in many cases prefereble to set up your lists on the host web and then just use the app web for a user interface, or if you don't want to utilize it at all: Just let the add-in do the heavy lifting in creating lists, columns and content types.
The important thing here is that you specify in your code that you want the lists to be created on the Host Web and not the App Web. For this to work you need to include a permission request in your app. When installed, the app will ask the user installing it if it can have permission to the host web. This is done by setting the relevant scope in your AppManifest.xml file, and then you set it under Permission: [your scope] - [permission level] You can read more about this at this resource: https://msdn.microsoft.com/en-us/library/office/fp142383.aspx
Then something like this code will allow you to create a list on your hostweb. Keep in mind that this list will still be available on the host web even if you remove your app.
oApp.install.addList = function (listName) {
var listCreationInfo = new SP.ListCreationInformation();
listCreationInfo.set_title(listName);
listCreationInfo.set_templateType(SP.ListTemplateType.genericList);
var myNewList = hostcontext.get_web().get_lists().add(listCreationInfo);
var dfd = $.Deferred();
context.load(myNewList);
context.executeQueryAsync(function () {
var listCreated = true;
console.log("[" + listName + "]" + " added to hostweb");
if (listCreated) dfd.resolve();
}, oApp.onFail
);
return dfd.promise();
};
I also wrote about creating certain types of columns on your list at my blog. Feel free to check that out here: http://bayerlein.se/how-to-create-host-web-lists-with-certain-columns-in-your-sharepoint-add-in-the-nice-way/

Related

Sharepoint error: Likes are not supported in this item

I'm trying to create a Sharepoint iOS app and using the rest api I get the error "Likes are not supported in this item." after doing a POST to https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')/like.
Anyone knows more about this kind of error?
The Rating settings seems to be set correctly on the Sharepoint server, because the like option works correctly on the website, and also in the app I can see the likesCount properties on the response for the Rest API call https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234').
I don't think there is something wrong with the client app implementation, but it is something related to the Sharepoint configuration, although I haven't seen any more settings in regards to the Rating settings including the Sharepoint access for the mobile app.
The web seems to handle this using the Microsoft.Office.Server.ReputationModel.Reputation.setLike function which again works correctly on the web parts, but I couldn't find a way to do it from the mobile app.
To set Likes for the list item, we need use the API below with POST request.
https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')
And pass the data of the POST request as below.
var item = {
"__metadata": { "type": "SP.Data.PagesItem"},
"LikedByStringId": {"results": ["11"]},
"LikesCount": 2
};
Before set Likes for the item, we need get the "LikedByStringId" and "LikesCount" value of the list item using API below with GET request, then set the new one.
https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')
Check the article here: Demonstrates how to like/unlike resource via SharePoint REST API

How to store custom user data on Netlify Identity?

I've been using Netlify for storing 100% of my app (both frontend and backend) for the last three months. So far, so good.
The only problem now is that I need to store a custom property for each user (say, the phone number), and apparently Netlify Identity doesn't support this (only email, name and roles https://www.netlify.com/docs/identity/).
I don't want to change the whole app to migrate to another hosting provider just for this detail (actually, I can't, it's for a client and I just don't have time), because it works great, but at the same time I need it.
Can you think of any workaround to this? The less "hackish", the better, but I understand that I'm going beyond the intended use of Netlify Identity.
So it actually does look like Netlify's GoTrue API has a specific endpoint for updating custom user data. After a user is created, you can update metadata by including it as "data" within an authenticated PUT request to /user.
PUT /user
{
"data" {
"custom_key": "value",
}
}
See https://github.com/netlify/gotrue for more info.
There are dozens of ways to do this, so I'll talk about two generally applicable ways now:
the most "generally capable" one is probably using lambda functions: https://www.netlify.com/docs/functions . This lets you run dynamic code, such as "store to database hosted elsewhere" or "email to our office manager to update a spreadsheet" or even "commit to our closed git repo so it's available in-code" (last one is probably a worst practice, but is possible). You can similarly use a function to read that data back out without exposing API tokens (code example: https://github.com/netlify/code-examples/tree/master/function_examples/token-hider)
you could have the data gathered via a form submission (https://www.netlify.com/docs/form-handling). I'd probably use zapier.com to receive a notification of the form submission (https://www.netlify.com/docs/form-handling/#notifications). Zapier can of course connect to just about anything on the planet :) . Getting the data back out if you want to show it in your UI is a bit more of a challenge, but you could use the above mentioned functions if you need to connect to some private data store to pull it out. Or for an MVP, just not show it, only let people enter/update it ;)

Sharepoint 2010 Break permission inheritance

I need to create a workflow that would break permission inheritance in a sharepoint subsite.
I am building a sharepoint 2010 site that is highly modular and can expand based on clients needs. The project requirement is that the client must be able to expand the website and add subsites from templates with as little interaction as possible. To this end I have created a list and attached a workflow to this list that creates a new website based on the information supplied in the list fields. The workflow I am using is a solution I found online http://www.ilovesharepoint.com/2011/02/create-site-action-sharepoint-designer.html
After the website is created I need to create security groups (another workflow I found online helps with this).
The problem is that the subsite must inherit security groups from the parent site and then I need to add new ones. In order to do this I need to break inheritance from the parent site and than I can create new groups. Currently my client has to do this manually - very bad thing. So I need create a workflow that would do just that.
The problem is that I am completely clueless as to how to go about doing this.
Ideally, I would like to create some sort of workflow action that would take a site url as input and then break permission. From what I've been able to find I need to use BreakRoleInheritance function to do that. but how do I create a workflow that takes input and how do i convert the string input into an actual site?
Like I said, I don't know anything about coding for sharepoint so please be as specific as possible.
Thank you very much.
P.S. maybe I am mistaken and i don't need to break inheritance to create additional security groups that would work only for a given subsite. If so, please tell me how to do this without breaking inheritance.

Programmatically accessing a Sharepoint list at runtime (without creating a service reference at design time)

I'm creating an app that will be configurable by the end-user to access SharePoint lists, on various different SharePoint sites, that are entered by the user.
All of the examples for reading SharePoint lists I've come across online are of the form:
Open or create a Visual Studio
project.
In Solution Explorer,
right-click the References node, and
then click Add Service Reference.
In the Address box, type the URL to
the target site and append
/_vti_bin/ListData.svc. For example,
the address for the site
intranet.wingtip.com would be
http://intranet.wingtip.com/_vti_bin/ListData.svc.
Change the default name in the
Namespace box from ServiceReference1
to something more appropriate, such
as WingtipSite.
etc, etc, etc
This method creates proxy classes within your project based on the specified server reference. However, in my case, the server/site is not known at design time, only runtime by reading the sites/lists specified by the user. How would one go about doing that (reading the list via http://intranet.wingtip.com/_vti_bin/ListData.svc, but at runtime only)?
Note: I am making this call from a different machine than the one running Sharepoint.
There are a couple answers.
If the lists schemas will be consistent across all the sites you are querying, you can still use the generated proxy. When you create the DataContext, you just need to pass in the URI to the ListData.svc for the site chosen by the user.
If not, then you can use an ASP.NET WebRequest with an appropriately formatted URI and parse out the ATOM or JSON response that comes back.
For more information on using the REST APIs, check out this talk from the 2009 SharePoint Conference
http://msdn.microsoft.com/en-us/sharepoint/ff462048
You can set the URL in your proxy class at runtime with the Url property.
SharePoint does not provide a proxy class for their web services. Therefore it's not possible to set the url at runtime. WHat I have had to do is add 2 service references and then paramaterize which one I will access. I use a config setting to determine which one to access. If the site name changes or list changes, then I need to remove the references, re-add them, recompile and redeploy. There is no way to change the SharePoint site/list at runtime. Have been searching for 3 days for an answer. Microsoft does not know how to accomplish this.

prevent duplicate site / page / layouts / templates / webparts, possible

We have a sharepoint environment with many sites (and sometimes many site collections). Each site (or site collection) has the same default page with some custom webparts that use sitecolumn values (for example a projectcode or clientcode) to show information from external systems. (for each project we have to create a separate site (or site collection) because of other reasons)
What is the best approach to minimize duplication? The dynamic parts of the page are stored in site columns. When we add a new webpart, ideally the default page every site/page should show the new webpart without spreading the update to the individual pages
Thanks
One approach you may want to take is to use the web part as a wrapper for a user control. The user control does the heavy lifting on the site. Once the web part is included on your pages, the user control should be able to tell which site it is being executed on and pull the necessary dynamic data from your site columns.
When you need to make updates, you update the user control and then redeploy the solution package to the farm. Each site will pick up the change as soon as the solution is deployed.
Here is a little information about this approach:
http://msdn.microsoft.com/en-us/library/ff649867.aspx.
The above article relates to WSS 3.0, but that should give you a starting point.
An approach you may want to look at for SharePoint 2010 is a visual web part. More info can be found here: http://msdn.microsoft.com/en-us/library/ff597539.aspx.