08-04-2018 04:35 AM
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="abcroject">
<title>Project</title>
<parent>cm:folder</parent>
<mandatory-aspects>
<aspect>abcrojectId</aspect>
<aspect>abcrojectName</aspect>
<aspect>abcrojectConsultantName</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: "abcroject",
destination: destination,
mode: "create",
submitType: "json",
formId: "doclib-common"
});
etc........
share-config-custom.xml
<config evaluator="model-type" condition="abcroject">
<forms>
<!-- Default Create Content form -->
<form id="doclib-common">
<field-visibility>
<show id="abcrojectId" />
<show id="abcrojectName" />
<show id="abcrojectConsultantName" />
<show id="abcman" />
</field-visibility>
<create-form template="../documentlibrary/forms/doclib-common.ftl" />
<appearance>
<field id="abcrojectId" />
<field id="abcrojectName" />
<field id="abcrojectConsultantName"/>
<field id="abcman" />
</appearance>
</form>
</forms>
</config>
08-04-2018 06:26 AM
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.
08-04-2018 07:09 AM
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.
08-04-2018 02:24 PM
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.
08-06-2018 12:49 AM
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?
08-06-2018 03:24 AM
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...
08-06-2018 07:48 AM
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).
basically, you need to override the "form.post.json.js" file.
Explore our Alfresco products with the links below. Use labels to filter content by product module.