Working with Entry Templates

The two states of the Entry Templates

Be careful with the Entry Template, they can have two states, retrieved or not retrieved. They contain a lot less information when they are not retrieved.

Here is how to check if it’s retrieved or not, and retrieve it if you need to:

if (!entryTemplate.isRetrieved) {
    // Retrieve it
    entryTemplate.retrieveEntryTemplate(lang.hitch(this, function (retrievedEntryTemplate) {
        // Do something with retrievedEntryTemplate
    }), false, true);
}

Here is the JSDoc of the ecm.model.EntryTemplate class, and the one of the retrieveEntryTemplate function. Actually the entry template object itself is updated so most of the time you won’t have to do anything in the callback except wait for it to happen. Example (function converting to classic callback to promise):

_retrieveET: function (et) {
    var def = new Deferred();
    et.retrieveEntryTemplate(function () {def.resolve(); });
    return def.promise;
},

Usage:

this._retrieveET(et).then(lang.hitch(this, function () {
    // Now the entry template is fetched, retrieved and fully usable
}));

 

And after doing some debugging for you, basically the difference between not retrieved and retrieved are:

icn_debug_et_not_retrieved

Entry template not retrieved

icn_debug_et_retrieved

Entry template retrieved

Retrieve all Entry Templates associated to a folder

ecm.model.Repository.retrieveEntryTemplates(callback, filter, folderId, rootFolderId, objectStore, onError)

JSDoc.

  • callback: what to do when the server return the answer
  • filter: filter what entry templates you want
    • null gives you every entry templates associated to the folder
    • ‘Document’ gives you document entry templates only
    • ‘Folder’ gives you folder entry templates only
    • They might be more but there is no documentation on this
  • folderId: the id of the folder
  • rootFolderId: no clue, maybe to stop the recursive search, I’m usually using null
  • objectStore: the object store
  • onError: what to do if any error occurs

Example:

repository.retrieveEntryTemplates(function (entryTemplates, document_ET_count, folder_ET_count) {
    var i, entryTemplate;
    for (i = 0; i < entryTemplates.length; i++) {
        tempEntryTemplate = entryTemplates[i];
        // Double check if it's a document ET even if we filtered to get only these ET
        if (tempEntryTemplate && tempEntryTemplate.type == "DOCUMENT") {
            // Here are all your Document Entry Template
        }
     }
}, "Document", folder.id, null, folder.objectStore);

What is available in an Entry Template

I won’t detail everything available in an entry template since you have the JSDoc for that. But quickly the most important things to consider when adding a document using an entry template are:

  • addClassName: the class to use to add the document
  • allowDuplicateFileNames: if we allow duplicate in the folder, to be passed to the add function
  • allowMinorVersion: let the choice to the user to add/check in as minor version or not
  • autoclassify: enable autoclassify or not, to be passed to the add function
  • permissions: the default permissions
  • folder: a mandatory folder to file new documents in
  • look at the other depending of your need, but you should use them to stay consistent with the overall repository behavior.

Access the Entry Template option value

As you may have noticed on the debug screen shots of the beginning of this post, most of the boolean options as asMinorVersion, autoClassify, checkInAsNewVersion and so on are not straight boolean. Instead, they are ecm.model.EntryTemplateOption, which looks like that:icn_debug_et_options

This is because they’ve got more information than just being on or off, they also tell you if the user should be able to change it or not with the readOnly property and to see it via the hidden property. If you want to be consistent in your wizard, you should use these values and enable/disable/hide your checkbox for these options accordingly.

Debug view

For those who like to see what’s going on inside the model, but who are too tired to start your developer tool 🙂 here is what the entire object looks like when it’s retrieved:

icn_debug_et_all

23 thoughts on “Working with Entry Templates

  1. Nikolai

    Hi!
    Didn’t you try to customize the Entry Template layouts and attribute editors? I mean Templare Manager provided in 2.0.3
    Is it possible to add custom attributes and see them in Template Designer and document editing form?

    Reply
  2. Guillaume Post author

    Hi Nikolai,

    I’m not sure I understood perfectly the question but let’s give it a try :).

    I guess when you are talking about custom attributes, you mean custom property on the class used by the entry template? If you are, then as soon as you’re using your custom class, you should see the new properties in the layout designer.
    Then the property should appear in the propertiesOptions array of the Entry Template object, with the default value, name, and some options like required, hidden and so on.
    If you change some look and field options in the layout designer, they are also stored in the object but in a different attribute, named markup:
    entry_template_debug

    Did you mean something else by custom attributes?

    Reply
  3. Nikolai

    No. I mean custom proprty editor. I.e. I want to add a new editor with it’s own brand new behaviour and look and see it both in Template Designer and rendered properties pane

    Reply
    1. Guillaume Post author

      Hi Nikolai,

      No, it just meant I was out yesterday 🙂 I think I get it now, you want to change the editor for the property. The Editor select list on the right in the Editor settings:

      editor_selector

      The choices depend on the type of the property. If you want to add a custom editor widget to that list, the mapping is done in the class “ecm/model/configuration/ControlRegistry”. Add a new editor in the editorConfigs attribute using your custom widget as editorClass, then map it to your type and cardinality in mappings.types attribute.

      To do this, dirty way is to change the file directly in the expanded directory of ICN (I would go with that at least to make sure it works). A better way would be to write a plugin modifying the mapping when loaded. I guess the best way would be to change the controlRegistryClass attribute of the class ecm/widget/entryTemplateBuilder/DesignerPane to yours custom registry which could be in a plugin:

      /**
      * A string value of the control registry class to be created.
      */
      controlRegistryClass: “ecm/model/configuration/ControlRegistry”,

      Hope it helps.

      Reply
      1. Nikolai

        I’ve found this ControlRegistry class already 🙂
        And now I’m hacking around to override it by my plugin.
        So I think it will be a good material for a post in your blog, if I succeed 🙂

        Reply
        1. Guillaume Post author

          For sure it would make a great post. Let me know if everything works as expected and I’ll try to write about it when I have more time. Hope that will work for you.

          Reply
          1. John

            I have wandered down the ControlRegistry path while trying to add a custom editor to an entrytemplate. I am not having much luck. Would you have a clear sample of how one would go about it?

  4. Suma

    Hi, It is really a very good website for developers. Thank you so much for the posts.

    I am customizing the drag and drop functionality of ICN. The requirement is to retrieve and display the entry template directly on drag & drop of a document on the search results of a search template. I have achieved it partially by overwriting the DndFromDesktopAddDoc.extend({
    displayDialog:function(files, targetItem, teamspace, defaultClass) function.
    But I am unable to retrieve a folder contentItem object from search template/ entry template in order to pass it into the function- addContentIremGeneralPane.setTargetLocation(parentFolderContentItem, repository, objectStoreObject, teamspace, false, false, true);

    The “entryTemplate.folder” is coming as null in the code, where as when I am debugging it in FireBug, I am able to retrieve the folder content Item. Could you please explain me how to retrieve the folder content item on drag and drop of a document on the search template results.

    Reply
  5. Deep

    Hi Nikolai,

    I have the same requirement, could you please share the sample code for me.
    It would of great help to me.

    Thanks in advance..

    Deep

    Reply
  6. Guillaume Post author

    Hi Nikolai,

    I don’t think you can, sorry about that. You should exchange directly with him or send it to me and I’ll add them to the post if you want it to be published.

    Thank you for being so reactive that’s nice to see.

    Guillaume

    Reply
  7. Nikolai

    Guillaume, tell me your email please (or send a message to my one). I’ll send you all neccessary files to make a post about this topic.

    Reply
  8. Deep

    Hi Nikolai / Guilaume

    Thanks for sharing the code base.
    In ReferenceBoxEditor.js there is a code snippet:

    define([
    “dojo/_base/declare”,
    “referenceDojo/widgets/ReferenceSelector”,
    “idx/form/_CompositeMixin”,
    “idx/form/_ValidationMixin”,
    “pvr/widget/editors/mixins/_EditorMixin”,
    “dojo/text!./templates//ReferenceBoxEditor.html”
    ],
    /**
    * An editor widget that extends some other generic widget (ReferenceSelector is my own 2.0.2 style property editor widget )
    * Other mixins must be present!
    * this object must have _setValueAttr and _getValueAttr methods
    */

    The file “referenceDojo/widgets/ReferenceSelector” is misssing in the zip file.
    Could you please help me by sendin that file as well, as I am getting run time error , ReferenceSelector is missing,

    Thanks,
    Deep Thakkar

    Reply
  9. Nikolai

    It is missing because it is out of the discussiion scope. You just should replace it with your own field widget.

    Reply
  10. Deep

    Hi Nikolai / Guilaume,

    I am trying to overload, multiValued integer field ie, an editable entry list to a String text box.
    I am able to deploy it, but when I edit the entry template and change the editor for that integer field, I am getting below error:

    Uncaught TypeError: Cannot read property ‘length’ of undefined

    is there any way to get it rectified or how can I retain the editable entry list with a button next to it.

    Please suggest.

    Thanks,
    deep

    Reply
  11. Nikolai

    Hi!
    You see, when you select your field in the template editor it is initialized like as it is placed on regular form. But th difference is that there are no any inbound parameters and deafault values. So your should provide this case in your widget. I thing that this is the error reason.

    Reply
  12. ven

    Hi Guillaume,

    Thank You for the information. I have one more question, is it possible to hide Search and Team pane from Teamspace using plug-ins?
    I really appreciate your help on this.

    Thanks

    Reply

Leave a Reply