Custom Content Model

79 views
Skip to first unread message

Craig Nelson

unread,
Mar 27, 2014, 6:06:40 PM3/27/14
to alfresco-techn...@googlegroups.com
I am working on a custom content model that has a property of document status. The allowed values are Pending, approved, paid, exported. 

When a document is uploaded the document is automatically marked as pending and the user can mark it as approved. 

There is a script that runs nightly that will export the metadata to a third party system and mark it as Exported. 

My question is how can I make it so that a user can only mark the document as pending or approved But they can not change it after it has been marked as exported or paid.

Any answers will be much appreciated. 

Thanks
Craig

Jeff Potts

unread,
Mar 27, 2014, 7:28:58 PM3/27/14
to alfresco-techn...@googlegroups.com
One way to do this would be to override the control for that particular property to point to a custom control that outputs non editable text when the field has that value, otherwise it produces the drop down.

Jeff
--
You received this message because you are subscribed to the Google Groups "Alfresco Technical Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alfresco-technical-d...@googlegroups.com.
To post to this group, send email to alfresco-techn...@googlegroups.com.
Visit this group at http://groups.google.com/group/alfresco-technical-discussion.
For more options, visit https://groups.google.com/d/optout.

Craig Nelson

unread,
Mar 29, 2014, 10:03:21 PM3/29/14
to alfresco-techn...@googlegroups.com
Jeff, 

Thanks for the advice. I am posting my code on here for others to see. 

I created this control by taking the selectone.ftl and changing the control. I put in bold the changes I made to it below

<#include "/org/alfresco/components/form/controls/common/utils.inc.ftl" />

<#if field.control.params.optionSeparator??>
   <#assign optionSeparator=field.control.params.optionSeparator>
<#else>
   <#assign optionSeparator=",">
</#if>
<#if field.control.params.labelSeparator??>
   <#assign labelSeparator=field.control.params.labelSeparator>
<#else>
   <#assign labelSeparator="|">
</#if>

<#assign fieldValue=field.value>

<#if fieldValue?string == "" && field.control.params.defaultValueContextProperty??>
   <#if context.properties[field.control.params.defaultValueContextProperty]??>
      <#assign fieldValue = context.properties[field.control.params.defaultValueContextProperty]>
   <#elseif args[field.control.params.defaultValueContextProperty]??>
      <#assign fieldValue = args[field.control.params.defaultValueContextProperty]>
   </#if>
</#if>

<div class="form-field">
   <#if form.mode == "view">
      <div class="viewmode-field">
         <#if field.mandatory && !(fieldValue?is_number) && fieldValue?string == "">
            <span class="incomplete-warning"><img src="${url.context}/res/components/form/images/warning-16.png" title="${msg("form.field.incomplete")}" /><span>
         </#if>
         <span class="viewmode-label">${field.label?html}:</span>
         <#if fieldValue?string == "">
            <#assign valueToShow=msg("form.control.novalue")>
         <#else>
            <#assign valueToShow=fieldValue>
            <#if field.control.params.options?? && field.control.params.options != "">
               <#list field.control.params.options?split(optionSeparator) as nameValue>
                  <#if nameValue?index_of(labelSeparator) == -1>
                     <#if nameValue == fieldValue?string || (fieldValue?is_number && fieldValue?c == nameValue)>
                        <#assign valueToShow=nameValue>
                        <#break>
                     </#if>
                  <#else>
                     <#assign choice=nameValue?split(labelSeparator)>
                     <#if choice[0] == fieldValue?string || (fieldValue?is_number && fieldValue?c == choice[0])>
                        <#assign valueToShow=msgValue(choice[1])>
                        <#break>
                     </#if>
                  </#if>
               </#list>
            </#if>
         </#if>
         <span class="viewmode-value">${valueToShow?html}</span>
      </div>
     <#else>
      <#if field.value=="Approved" || field.value=="Pending" >
      <label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
          <#if field.control.params.options?? && field.control.params.options != "">
         <select id="${fieldHtmlId}" name="${field.name}" tabindex="0"
               <#if field.description??>title="${field.description}"</#if>
               <#if field.control.params.size??>size="${field.control.params.size}"</#if>
               <#if field.control.params.styleClass??>class="${field.control.params.styleClass}"</#if>
               <#if field.control.params.style??>style="${field.control.params.style}"</#if>
               <#if field.disabled  && !(field.control.params.forceEditable?? && field.control.params.forceEditable == "true")>disabled="true"</#if>>
               <#list field.control.params.options?split(optionSeparator) as nameValue>
                  <#if nameValue?index_of(labelSeparator) == -1>
                                  <#if nameValue?html == "Approved" || nameValue?html == "Pending">
                     <option value="${nameValue?html}"<#if nameValue == fieldValue?string || (fieldValue?is_number && fieldValue?c == nameValue)> selected="selected"</#if>>${nameValue?html}</option>
                                  </#if>
                  <#else>
                     <#assign choice=nameValue?split(labelSeparator)>
                                        <#if choice[0]?html == "Approved" || choice[0]?html == "Pending">
                     <option value="${choice[0]?html}"<#if choice[0] == fieldValue?string || (fieldValue?is_number && fieldValue?c == choice[0])> selected="selected"</#if>>${msgValue(choice[1])?html}</option>
                        </#if>
                                 </#if>
               </#list>
         </select>
         <@formLib.renderFieldHelp field=field />
      <#else>
         <div id="${fieldHtmlId}" class="missing-options">${msg("form.control.selectone.missing-options")}</div>
      </#if>
             <#else>
            <label for="${fieldHtmlId}">${field.label?html}:</label>
                        <input id="${fieldHtmlId}" type="text" value="${field.value?html}" disabled="true"  title="${msg("form.field.not.editable")}"
             <#if field.control.params.styleClass??>class="${field.control.params.styleClass}"</#if>
             <#if field.control.params.style??>style="${field.control.params.style}"</#if> />
          </#if>
   </#if>
</div>






Reply all
Reply to author
Forward
0 new messages