cancel
Showing results for 
Search instead for 
Did you mean: 

how to modify content property in a workflow task from UI ?

ddzingielewski
Champ in-the-making
Champ in-the-making
Hi all, I am a newbie in Alfresco, I couldn't find any info about my issue looking into the forum, so I am here Smiley Happy
My isssue: I want to assign value from content metadata property (attached to workflow proces) to variable that is presented in the forms (Web CLient Alfresco).

I wanna do two things:
1)assign content property "sgn:Nazwa" to my task variable "ct_nazwa" and be able to display it on my web form.
2) update (after some user changes in UI in a step przegladTask) content property "sgn:Nazwa" from task variable ct_nazwa

My workflow model:

<?xml version="1.0" encoding="utf-8"?>
<model name="ct:pomyslModel"
xmlns="http://www.alfresco.org/model/dictionary/1.0">
  <description>Example Review And Approve Task Model</description>
  <author>Alfresco</author>
  <version>1.0</version>
  <imports>
    <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
    <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
    <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
    <import uri="pl.my" prefix="sgn" />
  </imports>
 
   <namespaces>
       <namespace uri="pl.my.ct.randd" prefix="ct"/>
   </namespaces>
   
  <types>
(…)
   <type name="ct:przegladTask">
      <parent>bpm:workflowTask</parent>
       <overrides>
           <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
           </property>
       </overrides>           
        <properties>
           <property name="ct:czyAkceptacjaPrzeglad">
              <type>d:boolean</type>
              <default>false</default>
           </property>
           <property name="ct:nazwa">
              <type>d:text</type>
           </property>
           <property name="ct:opisPomyslu">
              <type>d:text</type>
           </property>
           <property name="ct:kluczoweProblemy">
              <type>d:text</type>
           </property>         
           <property name="ct:sposobRozwiazaniaPotrzeby">
              <type>d:text</type>
           </property>         
        </properties>  
    </type>   
(…)
  </types> 
 
</model>

process definition:

<?xml version="1.0" encoding="UTF-8"?>

<process-definition  xmlns="urn:jbpm.org:jpdl-3.2"  name="pomysl">

(…)
   <task-node name="przeglad">
      <task name="ct:przegladTask" swimlane="lpp"></task>
      <event type="node-enter">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            
             ct_nazwa = bpm_package.children[0].properties["sgn:Nazwa"];
            </script>
         </action>
      </event>      
      <event type="node-leave">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
            bpm_package.children[0].properties["sgn:Nazwa"] =  ct_nazwa;
            </script>
         </action>
      </event>
      <transition to="czy do oceny ?"></transition>
   </task-node>

   <decision name="czy do oceny ?">
      <transition to="ocena" name="do oceny">
         <condition> #{ct_czyAkceptacjaPrzeglad}</condition>
      </transition>
      <transition to="do archiwum" name="to do archiwum"></transition>      
   </decision>

   (…)

</process-definition>

web-client-config-custom.xml:


<?xml version="1.0" encoding="utf-8"?>
<alfresco-config>

<!– pomysl forms –>
<config evaluator="string-compare" condition="Content Wizards">
   <content-types>
      <type name="sgn:Pomysl" />
   </content-types>
</config>
<config evaluator="node-type" condition="sgn:Pomysl">
    <property-sheet>
       <show-property name="mimetype" display-label-id="content_type" component-generator="MimeTypeSelectorGenerator" />
      <separator name="sep2" display-label="Inne właściwości" component-generator="HeaderSeparatorGenerator" />
        <show-property name="sgn:Nazwa" display-label="Nazwa"  />
        <show-property name="sgn:OpisPomyslu" display-label="Opis pomysłu" />
        <show-property name="sgn:PotrzebaZrodlowa" display-label="Potrzeba źródłowa" />
        <show-property name="sgn:SposobRozwiazaniaPotrzeby" display-label="Sposób rozwiązania potrzeby"  />
        <show-property name="sgn:KluczoweProblemy" display-label="Kluczowe problemy" />

       <show-association name="sgn:Autor" display-label="Autor" />
       <show-association name="sgn:Sponsor" display-label="Sponsor" />
       <show-association name="sgn:LeaderProspektu"  display-label="Lider prospektu"/>
        <show-property name="sgn:Uzasadnienie" display-label="Uzasadnienie" />
        <show-property name="sgn:Priorytet" display-label="Priorytet" />
        <show-property name="sgn:Status" display-label="Status"  />
        <show-property name="sgn:Kategoria" display-label="Kategoria" />
        <show-property name="sgn:DomenaSGN"  display-label="Domena"/>
    </property-sheet>
</config>
<config evaluator="string-compare" condition="Advanced Search">
    <advanced-search>
    <content-types>
    <type name="sgn:Pomysl" />
    </content-types>
    <custom-properties>
    <meta-data type="sgn:Pomysl" />
    </custom-properties>
    </advanced-search>
</config>

<config evaluator="node-type" condition="ct:przegladTask"
replace="true">
  <property-sheet>
    <separator name="sep1" display-label-id="general"
    component-generator="HeaderSeparatorGenerator" />
    <show-property name="bpm:taskId" />
    <show-property name="bpm:description"
    component-generator="TextAreaGenerator" read-only="true" />
    <show-property name="ct:nazwa" />
  </property-sheet>
</config> 
</alfresco-config>


my content model:

<model name="sgn:randdPomyslModel"
xmlns="http://www.alfresco.org/model/dictionary/1.0">
  <description>Model Pomysłu</description>
  <author>dd</author>
  <version>1.0</version>
  <imports>
    <!– Import Alfresco Dictionary Definitions –>
    <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
    <!– Import Alfresco Content Domain Model Definitions –>
    <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
  </imports>
   <namespaces>
       <namespace uri="pl.my" prefix="sgn"/>
   </namespaces>
(…)
  <types>
    <type name="sgn:Pomysl">
        <title>Pomysł dla Research And Development</title>
        <parent>cm:content</parent>
        <properties>
(…)
           <property name="sgn:Nazwa">
              <title></title>
                <type>d:text</type>
           </property>
           <property name="sgn:OpisPomyslu">
              <title>Ogólny opis pomysłu</title>
                <type>d:text</type>
           </property>
           <property name="sgn:PotrzebaZrodlowa">
              <title>Problem/potrzeba źródłowa</title>
                <type>d:text</type>
           </property>
           <property name="sgn:SposobRozwiazaniaPotrzeby">
              <title>Sposób rozwiązania problemu/zaspokojenia potrzeby</title>
                <type>d:text</type>
           </property>
           <property name="sgn:AktualneSposobyRozwiazania">
              <title>Aktualnie stosowane sposoby rozwiązywania problemu/zaspakajania potrzeby </title>
                <type>d:text</type>
           </property>
           <property name="sgn:SzacunkowaWielkoscRynku">
              <title>Szacunkowa wielkość rynku docelowego</title>
                <type>d:text</type>
           </property>
           <property name="sgn:CechyUnikalnePomyslu">
              <title>Cechy unikalne charakteyzujące pomysł</title>
                <type>d:text</type>
           </property>
           <property name="sgn:KluczoweProblemy">
              <title>Kluczowe problemy dot. wdrożenia pomysłu/wykonalności rozwiązania </title>
                <type>d:text</type>
           </property>
           <property name="sgn:SposobGenerowaniaWartosci">
              <title>Sposób generowania wartości </title>
                <type>d:text</type>
           </property>
      </properties>
  </type>
(…)
 
</model>

thanks for any help
dd
3 REPLIES 3

granddams
Champ in-the-making
Champ in-the-making
Hi,

i'm not familiar with workflows in jbpm (try activiti, jbpm will no longer be maintained), but i think i can help you.

Your models are good, i may change the web-client-config. Rather show properties of your object ct:


<config evaluator="node-type" condition="sgn:Pomysl">
    <property-sheet>
        <show-property name="ct:nazwa" display-label="Nazwa"  />
        <show-property name="ct:opisPomyslu" display-label="Opis pomysłu" />
        <show-property name="ct:kluczoweProblemy" display-label="Kluczowe problemy" />
(…)

And for your process-definition, i should use variables assigned directly to tasks, such as:


<event type="node-enter">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
               task.setVariable('ct_nazwa', bpm_package.children[0].properties["sgn:Nazwa"]);
         </script>
         </action>
      </event>     
      <event type="node-leave">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
                bpm_package.children[0].properties["sgn:Nazwa"] =  task.getVariable('ct_nazwa');
         </script>
(…)

ddzingielewski
Champ in-the-making
Champ in-the-making
thanks for Your answer, You've helped me to go few steps further
Your exact snippet didn't work, but it had inspired me to search in a different way and helped me to find out that:
when I set web-client-config just as You set, and when I try this:

<event type="node-enter">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
              executionContext.getContextInstance().setVariable('ct_nazwa', bpm_package.children[0].properties["sgn:Nazwa"]);
         </script>
         </action>
      </event>     
      <event type="node-leave">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
                bpm_package.children[0].properties["sgn:Nazwa"] =   executionContext.getContextInstance().getVariable('ct_nazwa');
         </script>
(…)

it almost Smiley Happy works, I mean: I can get a value from a field from content, then I can display it in a UI, then I can change it on UI and save it to  bpm_package.children[0].properties["sgn:Nazwa"] during first step and finally I can display that value in second step. There is only one thing i do not understand: When i navigate on my task (the second step) UI to  Resources->Actions->Edit Content Properties I still see the old value. So it seems that I have already changed only on some kind of a copy of a metadata. How to make update on original content metadata ?

granddams
Champ in-the-making
Champ in-the-making
Oups, sorry!  :lol:
Like you, i forgot the usual magic line:

bpm_package.children[0].save();

Without it, document is not updated…