Custom Folder Type

cancel
Showing results for 
Search instead for 
Did you mean: 
sanjaybandhniya
Intermediate

Custom Folder Type

I have created custom folder with custom type with the help of onNewFolder action.Just changing itemId.

Custom folder have field like field1,field2 etc.... There is no cm:name property in that custom type.

Node is created but name is something like 'c3ee5007-296e-4dfa-a642-e5a26ca364fa' but i want to assign name like field1_field2.

How can i do that?

Custom Type : 

<types>
<type name="abcSmiley Tongueroject">
      <title>Project</title>
      <parent>cm:folder</parent>

<mandatory-aspects>
      <aspect>abcSmiley TonguerojectId</aspect>
      <aspect>abcSmiley TonguerojectName</aspect>
      <aspect>abcSmiley TonguerojectConsultantName</aspect>
      <aspect>abc:region</aspect>
</mandatory-aspects>
</type>
</types>

toolbar.js 

this.widgets.newMOTCFolder = Alfresco.util.createYUIButton(this, "newMOTCFolder-button", this.onNewMOTCFolder,
{
   disabled: true,
   value: "CreateChildren"
});

var templateUrl = YAHOO.lang.substitute(Alfresco.constants.URL_SERVICECONTEXT + "components/form?itemKind={itemKind}&itemId={itemId}&destination={destination}&mode={mode}&submitType={submitType}&formId={formId}&showCancelButton=true",
{
      itemKind: "type",
      itemId: "abcSmiley Tongueroject",
      destination: destination,
      mode: "create",
      submitType: "json",
      formId: "doclib-common"
});

etc........

share-config-custom.xml

<config evaluator="model-type" condition="abcSmiley Tongueroject">
<forms>
<!-- Default Create Content form -->
   <form id="doclib-common">
      <field-visibility>
      <show id="abcSmiley TonguerojectId" />
      <show id="abcSmiley TonguerojectName" />
      <show id="abcSmiley TonguerojectConsultantName" />
      <show id="abcSmiley Surprisedman" />
</field-visibility>
<create-form template="../documentlibrary/forms/doclib-common.ftl" />
<appearance>
      <field id="abcSmiley TonguerojectId" />
      <field id="abcSmiley TonguerojectName" />
      <field id="abcSmiley TonguerojectConsultantName"/>
      <field id="abcSmiley Surprisedman" />
</appearance>
</form>
</forms>
</config>

6 Replies
afaust
Master

Re: Custom Folder Type

Then you need to either implement a folder rule or a behaviour to set the cm:name property to a value concatenated from the values of the two fields. For a behaviour, the OnCreateNode policy might be useful. If you want to keep the name synchronized to the values of the two fields, you may also want to implement the OnUpdateProperties policy.

sanjaybandhniya
Intermediate

Re: Custom Folder Type

Hi,

Here field1 and field2 are combobox.

My condition is that same folder name should not be repeated then how can I full fill that? Because rule is executed after node creation.

afaust
Master

Re: Custom Folder Type

If you base the name on these fields, and two nodes use the same values for these fields, then their name will conflict, and saving will fail, giving user the chance to pick different values.

sanjaybandhniya
Intermediate

Re: Custom Folder Type

Here,First node is created then rule will apply and rule is prevented to assign same name so what about that created node.Do we need to delete that node and display message that name is already exist?

afaust
Master

Re: Custom Folder Type

The rule is applied as part of the transaction (provided you do not explicitly specify to run it "in the background"). So if the rule changes the name to something that conflicts, then the conflict is detected and the transaction is rolled back. No need to delete anything, because rolling back the transaction means everything is undone...

ratik_singhal
Established Member

Re: Custom Folder Type

Hello You can achieve this by the combination of behavior (NodeServicePolicies.OnUpdatePropertiesPolicy)
and overriding the front end validation while submitting the form (If you are not using java webscript to create folder).

Check this url -  

basically, you need to override the "form.post.json.js" file.