How do I create a SharePoint 2007 list from a template via web service? - sharepoint

I have a SharePoint 2007 custom list that I have saved as a list template. I am looking for a way to create a new list from the saved template via a web service call from an outside application.
I have already looked into the the basic web services available for SharePoint 2007 http://msdn.microsoft.com/en-us/library/bb862916(office.12).aspx but a call to that just creates a simple, empty custom list.
How do I instantiate a list from a specific template? How do I locate the Feature ID for the template?

You can use a HTTP debugger like fiddler2 to analyze the web service and remote procedure calls that SharePoint Designer makes to find this out.
For example, to get the available list templates, SPD makes an HTTP request using the DisplayPost RPC command, e.g.
POST http://[server]/[web]/_vti_bin/owssvr.dll?Cmd=DisplayPost
with an xml payload of:
<?xml version="1.0" encoding="UTF-8"?>
<ows:Batch OnError="Return" Version="12.0.0.000">
<Method ID="0,GetProjSchema">
<SetVar Name="Cmd">GetProjSchema</SetVar>
</Method>
</ows:Batch>
SPD then parses the ListTemplates node in the response to obtain a list of template names, types, and feature IDs.
To create the list from a specific template type or feature ID, SPD uses the same DisplayPost command, this time with a message body similar to:
<?xml version="1.0" encoding="UTF-8"?>
<ows:Batch OnError="Return" Version="12.0.0.000">
<Method ID="0,NewList">
<SetVar Name="Cmd">NewList</SetVar>
<SetVar Name="ListTemplate">108</SetVar>
<SetVar Name="Title">Discussion Board</SetVar>
<SetVar Name="FeatureId">00bfea716a4943fab535d15c05500108</SetVar>
<SetVar Name="RootFolder" />
<SetVar Name="LangID">1033</SetVar>
</Method>
</ows:Batch>
For an example of how to use the RPC protocol see this post on uploading files to a SharePoint document library (it uses the author.dll rather than the owssvr.dll, but the technique is similar).

Related

Sharepoint Online Edit Form Toolbar

I'm trying to create a custom action on the edit form on Sharepoint Online with a Sharepoint Add-in..
According to the documentation, I should be able to use EditFormToolbar location as follows:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="965225e0-662b-4089-acdc-78433528f646.TestMenuAction"
RegistrationType="List"
RegistrationId="{$ListId:Lists/Add-in List Test;}"
Location="EditFormToolbar"
Sequence="10"
Title="Test Button">
<!--
Update the Url below to the page you want the custom action to use.
Start the URL with the token ~remoteAppUrl if the page is in the
associated web project, use ~appWebUrl if page is in the app project.
-->
<UrlAction Url="~appWebUrl/Pages/LookupWebPart.aspx?{StandardTokens}&SPListItemId={ItemId}&SPListId={ListId}" />
</CustomAction>
</Elements>
But this fails to deploy with the following error:
#"Error 1
CorrelationId: 817f7325-e9bc-41da-ae9f-400b459ce1cf
ErrorDetail: There were problems with the app web definition in the package.
ErrorType: App
ErrorTypeName: App Related
ExceptionMessage: Deployment failed in host web https://<redacted>.sharepoint.com/sites/dev.addin for app <redacted>/ca27c77f-c56f-409d-a69d-7064091fdda4. Microsoft.SharePoint.SPException: Feature definition with Id ca27c77f-c56f-409d-a69d-7064091fdda5 failed validation, file '/elements33b5f3d1-0607-455b-b292-880b39ec127d.xml', line 6, character 17: The 'Location' attribute is invalid - The value 'NewFormToolbar' is invalid according to its datatype 'http://schemas.microsoft.com/sharepoint/:CustomActionLocations' - The Enumeration constraint failed.
The schema documentation instead suggests that only CommandUI.Ribbon and EditControlBlock are supported locations.
Does anyone know if it's possible to customise the Edit Toolbar in Sharepoint Online?

SharePoint hosted app custom list form upgrade

I created a SharePoint Hosted add-in with custom list form as directed in
https://blogs.msdn.microsoft.com/wilsonreddygajarla/2014/12/13/sharepoint-list-newform-customization-in-sharepoint-hosted-app/
All, works great until you want to upgrade the add-in with changes to your custom form. I have tried the following approaches:
Created a module entry within the list element.xml with ReplaceContent=True which deploys successfully but does not replace the form with new changes.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="CustomList">
<File Url="NewItem.aspx" Path="CustomList/NewItem.aspx" ReplaceContent="TRUE" />
</Module>
<!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List project item, an error will occur when the project is run. -->
<ListTemplate ...`
Tried to reference a custom form page from Pages module but the Path in Schema.xml somehow keeps looking for the custom form within the List Definition folder.

How to use Google Apps Script to serve a Google Calendar/Email gadget?

I would like to develop a calendar/gmail gadget for our Google Apps for Business domain using Apps Script to leverage all of the benefits it affords.
When replicating the Hello World gadget example:
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="hello world example" />
<Content type="html">
<![CDATA[
Hello, world!
]]>
</Content>
</Module>
Using a template XML doGet():
function doGet(e) {
var output = ContentService.createTextOutput();
var xml = '<?xml version="1.0" encoding="UTF-8" ?>\n<Module>\n<ModulePrefs title="Calendar Gadget" />\n<Content type="html"><![CDATA[\nHello, world!\n]]></Content>\n</Module>';
output.setContent(xml);
output.setMimeType(ContentService.MimeType.XML);
return output;
}
The resultant served content is identical to the example Gadget which installs fine, but served from GAS it isn't recognised as valid. Calendar ignores it and GMail declares it invalid.
Invalid gadget specification. Ensure that URL is correct and the gadget does not contain errors.
Is part of the requirement for a Google Apps Gadget that it be served using an *.xml filename?
doGet() does not return the XML (or HTML) verbatim. There is a difference in the exact content provided to the browser and the content returned by doGet().
So, the answer to your question is - yes, you need to have an XML file for a Google Gadget and cannot use Apps Script. What you can perhaps do is use Apps Script to write out the XML file.
The content served using the ContentService should be identical to the input provided. Please ensure that the web app is configured to allow anonymous access.

Using the default approval workflow task form in a custom Visual Studio Workflow

I am making a custom approval workflow in VS, but I dont wan to create a custom infoPah form to create the task edit form. Is there any way to use the form that comes with the OOTB approval workflow??
Thanks
You should try to specify the URN of OOTB InfoPath form in Elements.xml of your workflow solution.
Example:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Workflow
Name="WorkflowProject1 - Workflow1"
Description="My SharePoint Workflow"
Id="1ac59aff-6d65-4e7c-9dc1-e84e7cbc6b3a"
CodeBesideClass="WorkflowProject1.Workflow1.Workflow1"
CodeBesideAssembly="$assemblyname$">
<Categories/>
<MetaData>
<AssociationCategories>List</AssociationCategories>
<!-- Tags to specify InfoPath forms for the workflow; delete tags for forms that you do not have -->
<!--<Association_FormURN>[URN FOR ASSOCIATION FORM]</Association_FormURN>
<Instantiation_FormURN>[URN FOR INSTANTIATION FORM]</Instantiation_FormURN>
--><Task0_FormURN>urn:schemas-microsoft-com:office:infopath:workflowInitAssoc:-AutoGen-2009-07-30T07:17:57:12Z:1033</Task0_FormURN><!--
<Task1_FormURN>[URN FOR TASK (type 0) FORM]</Task1_FormURN>-->
<!-- Modification forms: create a unique guid for each modification form -->
<!--<Modification_[UNIQUE GUID]_FormURN>[URN FOR MODIFICATION FORM]</Modification_[UNIQUE GUID]_FormURN>
<Modification_[UNIQUE GUID]_Name>[NAME OF MODIFICATION TO BE DISPLAYED AS A LINK ON WORKFLOW STATUS PAGE</Modification_[UNIQUE GUID]_Name>
-->
<StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl>
</MetaData>
</Workflow>
</Elements>
You can check installed InfoPath Templates in Central Administration > General Application Settings > Manage Form Templates > when you click on template you could see the form URN.
Hope it helps.

WSS 3.0 Site Definition breaks when including MasterUrl in onet.xml

I have created a simple site definition for WSS 3.0 which uses a feature, this feature provisions a master page into the masterpage gallery.
This works absolutely fine, and once I've created a site from the definition I can go into the masterpage gallery and view my provisioned file.
If, however, I set the MasterUrl in my Configuration node of onet.xml and then create a new site from it, it fails. After clicking create it redirects me to the new site automatically but presents me with a file not found error. So I type in the url to the settings page and click to view the masterpage gallery which then gives me a file not found error again.
I'm not sure what's going on, but it looks to me like setting the MasterUrl prevents it from creating the correct lists to which the feature can provision the masterpage to. Can anyone shed any light on this matter for me please?
Here is the webtemp*.xml:
<?xml version="1.0" encoding="utf-8"?>
<Templates>
<Template Name="MasterPageTest" ID="10902">
<Configuration ID="0"
Title="MasterPageTest"
Description="Testing master page deployment"
Hidden="FALSE"
ImageUrl="/_layouts/images/stsprev.png"
DisplayCategory="Test"
/>
</Template>
</Templates>
And the onet.xml (with the masterurl attribute removed):
<?xml version="1.0"?>
<Project Title="MasterPageTest" Revision="3" ListDir="$Resources:core,lists_Folder;" xmlns:ows="Microsoft SharePoint" xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- _locID#Title="camlidonet1" _locComment="{StringCategory=HTX}" -->
<NavBars>
</NavBars>
<ListTemplates>
</ListTemplates>
<DocumentTemplates>
</DocumentTemplates>
<Configurations>
<Configuration ID="0"
Description="Testing master page deployment"
Title="Master Page Test"
Name="MasterPageTest"
>
<!-- MasterUrl="_catalogs/masterpage/MasterPage.master" -->
<Lists>
</Lists>
<Modules>
</Modules>
<SiteFeatures>
</SiteFeatures>
<WebFeatures>
<!-- Masterpage -->
<Feature ID="8175B375-38F5-44E2-950A-9600D5427E17"/>
</WebFeatures>
</Configuration>
</Configurations>
<Modules>
</Modules>
<ServerEmailFooter>$Resources:ServerEmailFooter;</ServerEmailFooter>
</Project>
My first thought was: Why in the onet.xml?
I usually do this using a process called Feature stapling. It is impossible to remove / disable functionality created from a site definition later on (off course you could by hand, or a feature + receiver to remove say a list you don't need for a particular site created from the onet.xml, but you probably get the point).
By using feature stapling, (your / the) site definition stays clean and stays what it is meant to be: a definition of a site, that can be selected during site creation. IMHO, it should be nothing more than an empty container.
Feature Stapling binds features you want activated when a site is created to a (custom) siteTEMPLATE. You can even use this to attach features you want activated on out of the box site definitions as well. For instance, feature stapling is the preferred way of enabling features in the "MySite" and "My Site Host" definitions. The original sitedefintion remains untouched, but your features are activated too!
Now to actually answer your question: The masterpage is probably not available yet when the site definition is used, the onet.xml is processed before any features are activated.
If your site is a publishing site (meaning the publishing related features are activated in the site collection), you can set the masterpage in the Publishing Feature with the ChromeMasterUrl property.
If the site is a regular site, you can do 2 things:
deploy the master page from the onet.xml by moving the <Module> from your masterpage feature to the onet.xml, more info here (figure 1).
don't set the masterpage url in the onet, but use a feature + featurereceiver to set the masterpage url, more info here (downloadable code in article).

Resources