Create an entry template programmatically 

To create an entry template, create or retrieve an entry, edit its Atom entry document, and then send a post request to pass the document to the server as a multipart post.

Table 1. Atom API entry request details

Method Resource URI Input representation
POST activity collection Value of the href attribute of the <app:collection> element of the activity. Multipart post containing:

  • Entry template Atom document

  • Icon graphic


To create an entry template...

  1. Create an activity, if necessary.

  2. Create the entry or to-do item that you want to use as the template. Or, if an entry or to-do item already exists that you want to reuse as the template, retrieve that entry or to-do item. See Retrieve activity nodes.

  3. Edit the Atom document for the entry or to-do item to identify it as an entry template. Change the term attribute of the category element to entrytemplate. For example, change this:

      <category 
       scheme="http://www.ibm.com/xmlns/prod/sn/type" 
       term="entry"></category>

      to this:

      <category 
       scheme="http://www.ibm.com/xmlns/prod/sn/type" 
       term="entrytemplate"></category>

      This ensures that the entry template contains the atom:id of the source entry document as its atom:id.

  4. Use the multipart post method, like the method you use to post attachments, send a post request to an activity collection that contains the new entry template document as the first body part and an icon image file as the second body part.

      The icon image that you provide is associated with the template so that whenever a person creates a new entry based on the template, this icon is displayed beside the custom entry title in the Activities views.

  5. If the entry template creation is successful, an entry template Atom document is returned. It contains two new hidden, read-only text fields:

      $nodeType

        Specifies the entry type of the source entry.

      $icon

        Identifies the icon associated with entries created using this template.

Input

Provide the following content as a multipart post:

Note: Specify the content type of the Atom entry document as multipart/related;type="application/atom+xml".


Output

None.

Returned HTTP headers

HTTP/1.1 201 Created

Location: url

Error codes

HTTP Request:

POST http://activities.enterprise.example.com/service/atom2/
 activity?activityUuid=
 235G09219C738340135B8B243F4049000228 HTTP/1.1
Host: localhost
Content-Type: 
 multipart=related;type="application/atom+xml"
Authorization: xxxx
Content-Length: nnn 
--MIME_boundary
  Content-Type: application/atom+xml; charset="UTF-8"
  Content-ID: <start id of entry xml file> 
<entry xmlns="http://www.w3.org/2005/Atom">
  <id>urn:lsid:ibm.com:oa:
      537G09219C738340135B8B243F404900022C</id>
  <title type="text">New entry template</title>
  <updated>2009-01-02T17:31:59Z</updated>
  <published>2009-01-02T17:31:59Z</published>
  <author>
    <name>donquixote@dulcinea.com</name>
    <email>donquixote@dulcinea.com</email>
    <snx:userid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
     donquixote@dulcinea.com
    </snx:userid>
    <snx:ldapid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
     177G09219C7341D31A078B4D3F1552000000
    </snx:ldapid>
  </author>
  <contributor>
    <name>donquixote@dulcinea.com</name>
    <email>donquixote@dulcinea.com</email>
    <snx:userid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
     donquixote@dulcinea.com
    </snx:userid>
    <snx:ldapid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
     177G09219C7341D31A078B4D3F1552000000
    </snx:ldapid>
  </contributor>
     
  <category 
   scheme="http://www.ibm.com/xmlns/prod/sn/type" 
   term="entrytemplate" 
   label="Entry Template">
  </category>
  <thr:in-reply-to 
   xmlns:thr="http://purl.org/syndication/thread/1.0" 
   ref="urn:lsid:ibm.com:oa:235G09219C738340135B8B243F4049000228" 
   type="application/atom+xml" 
   href="http://activities.enterprise.example.com/service/atom2/activitynode?
         activityNodeUuid=235G09219C738340135B8B243F4049000228" 
   source="urn:lsid:ibm.com:oa:
           235G09219C738340135B8B243F4049000228">
  </thr:in-reply-to>
  <snx:activity 
   xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
    235G09219C738340135B8B243F4049000228
  </snx:activity>
 
  <link 
   rel="edit" 
   type="application/atom+xml" 
   href="http://activities.enterprise.example.com/service/
         atom2/activitynode?activityNodeUuid=
         537G09219C738340135B8B243F404900022C" >
  </link>
  <link 
   rel="self" 
   type="application/atom+xml" 
   href="http://activities.enterprise.example.com/service/
    atom2/activitynode?activityNodeUuid=
    537G09219C738340135B8B243F404900022C" >
  </link>
  <link 
   rel="alternate" 
   type="application/xhtml+xml" 
   href="http://activities.enterprise.example.com/service/html/activityentry?
         uuid=537G09219C738340135B8B243F404900022C" >
  </link>
  <link 
   rel="alternate" 
   type="text/html" 
   href="http://activities.enterprise.example.com/service/html/activityentry?
         uuid=537G09219C738340135B8B243F404900022C" >
  </link>
  <snx:position xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
   1000
  </snx:position>
  <snx:depth xmlns:snx="http://www.ibm.com/xmlns/prod/sn">1</snx:depth> 
 
  <snx:permissions xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
   none, create_activity, view_activity, edit_activity, delete_activity, 
   activity_owner, edit_activity_tags, design_activity, edit_statements, 
   delete_statements, add_members, delete_members, create_entries, 
   edit_personal_entries, edit_all_entries, delete_personal_entries, 
   delete_all_entries, edit_personal_entry_tags, edit_all_entry_tags, 
   view_members
  </snx:permissions>
  <content type="text">
   New entry from entry template test
  </content>
  <snx:field 
   xmlns:snx="http://www.ibm.com/xmlns/prod/sn" 
   name="new link" fid="5C8G09219C738340135B8B243F404900022E" 
   position="1000" 
   type="link">
   <link href="http://www.ibm.com" title="IBM"></link>
  </snx:field>
</entry>
  --MIME_boundary
  Content-Type: image/jpg
  Content-ID: <image file id of donquixote.jpg>
  Content-Length: nnnn
  Slug: Don Quixote Image 
(binary data of Don Quixote Image file)

HTTP Response:

Content returned by the server:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom"
  xmlns:app="http://www.w3.org/2007/app"  
  xmlns:snx="http://www.ibm.com/xmlns/prod/sn"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns:thr="http://purl.org/syndication/thread/1.0"
  >
  <id>urn:lsid:ibm.com:oa:885G09219C738340135B8B243F4049000210</id>
  <title type="text">New entry template</title>
  <updated>2009-01-02T15:08:06Z</updated>
  <published>2009-01-02T15:08:06Z</published>
  <author>
    <name>donquixote@dulcinea.com</name>
    <email>donquixote@dulcinea.com</email>
    <snx:userid>donquixote@dulcinea.com</snx:userid>
    <snx:ldapid>177G09219C7341D31A078B4D3F1552000000</snx:ldapid>
  </author>
  <contributor>
    <name>donquixote@dulcinea.com</name>
    <email>donquixote@dulcinea.com</email>
    <snx:userid>donquixote@dulcinea.com</snx:userid>
    <snx:ldapid>177G09219C7341D31A078B4D3F1552000000</snx:ldapid>
  </contributor>
     
  <category 
   scheme="http://www.ibm.com/xmlns/prod/sn/type" 
   term="entrytemplate" 
   label="Entry Template"/>
  <thr:in-reply-to 
   ref="urn:lsid:ibm.com:oa:AB9G09219C738340135B8B243F4049000209"
   type="application/atom+xml"
   href="http://activities.enterprise.example.com/service/atom2/activitynode?
         activityNodeUuid=AB9G09219C738340135B8B243F4049000209"
   source="urn:lsid:ibm.com:oa:AB9G09219C738340135B8B243F4049000209"/>
  <snx:activity>AB9G09219C738340135B8B243F4049000209</snx:activity>
 
  <link 
   rel="edit" 
   type="application/atom+xml" 
   href="http://activities.enterprise.example.com/service/atom2/activitynode?
         activityNodeUuid=885G09219C738340135B8B243F4049000210" />
  <link 
   rel="self" 
   type="application/atom+xml" 
   href="http://activities.enterprise.example.com/service/atom2/activitynode?
         activityNodeUuid=885G09219C738340135B8B243F4049000210" />
  <link 
   rel="alternate" 
   type="application/xhtml+xml" 
   href="http://activities.enterprise.example.com/service/html/activityentry?
         uuid=885G09219C738340135B8B243F4049000210" />
  <link 
   rel="alternate" 
   type="text/html" 
   href="http://activities.enterprise.example.com/service/html/activityentry?
         uuid=885G09219C738340135B8B243F4049000210" />
  <snx:position>2000</snx:position>
  <snx:depth>1</snx:depth> 
  <snx:permissions>
   none, create_activity, view_activity, edit_activity, delete_activity, 
   activity_owner, edit_activity_tags, design_activity, edit_statements, 
   delete_statements, add_members, delete_members, create_entries, 
   edit_personal_entries, edit_all_entries, delete_personal_entries, 
   delete_all_entries, edit_personal_entry_tags, edit_all_entry_tags, 
   view_members
  </snx:permissions>
  <summary type="text"></summary>
  <snx:field 
   name="new link"  
   fid="B1CG09219C738340135B8B243F4049000211" 
   position="1000" 
   type="link" >
    <link href="" title=" " />
  </snx:field>
  <snx:field 
   name="$nodeType"  
   fid="05EG09219C738340135B8B243F4049000212" 
   position="2000" 
   type="text" 
   hidden="true">
    <summary type="text">activities/entry</summary>
  </snx:field>
  <snx:field 
   name="$icon"  
   fid="8B9G09219C738340135B8B243F4049000214" 
   position="3000" 
   type="file" 
   hidden="true">
    <link 
     rel="enclosure" 
     type="image/jpeg" 
     href="http://activities.enterprise.example.com/service/download/
           460G09219C738340135B8B243F4049000215/icon_Don+Quixote+Image.jpg" 
     size="704"/>
    <link 
     rel="edit-media" 
     type="image/jpeg" 
     href="http://activities.enterprise.example.com/service/download/
           460G09219C738340135B8B243F4049000215/icon_Don+Quixote+Image.jpg" 
     size="704"/>
  </snx:field>
</entry>


Parent topic

Work with entry templates programmatically

Related reference
Retrieve activity nodes
Entry template content


   

 

});