Community articleCreating an entry template programmatically
Added by IBM contributorIBM on April 30, 2014
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

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.



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.

To create an entry template, complete the following steps:

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 Retrieving 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. Using 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. Note: Specify the content type of the Atom entry document as multipart/related;type="application/atom+xml".

Output

None.

Input
Method URI Description
POST /activities/service/atom2/activities Value of the href attribute of the <app:collection> element of the activity.
Content Type: application/atom+xml
Sample Request:
<?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:93f28c0e-617f-4d67-8ebc-31ef101802c0</id>
<title type="text">New1</title>

<category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="entrytemplate"/>
 
<thr:in-reply-to ref="urn:lsid:ibm.com:oa:60eac668-ab21-4795-b112-51eeaf54ffaa"
type="application/atom+xml"
href="https://greenhousestage.lotus.com/activities/service/atom2/activitynode?activityNodeUuid=60eac668-ab21-4795-b112-51eeaf54ffaa"
source="urn:lsid:ibm.com:oa:60eac668-ab21-4795-b112-51eeaf54ffaa"
/>

<content type="html">
</content>
</entry>
Name Type Optional Description
activityUuid
string No The UUID of the Activity.
Output
Name Type Optional Description
Location
string No Link to edit_url of the new entry template that can be used to update it.
Code Description
201
Indicates that the entry template was successfully created. If an error occurs, this header contains one of the error codes.
400
Bad Request.
403
Forbidden. Authorization failed.
Examples
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)


Response 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>