cancel
Showing results for 
Search instead for 
Did you mean: 

Dropbox Java Script // found solution

thestorm
Champ in-the-making
Champ in-the-making
Hey people, I didnt find sth related to my problem so  I start a post, maybe some1 has more experience than me.

I have some custom propertys like customer (list) and I wanna make a JS for my dropbox that moves the document to the folder of the customer.

I have 2 Problems,

1. how to trigger a JS after i edited the properties (does on Update work here? Because Inbound triggers the script before i can set my properties)

2. how to use Paths in document.move i only found space.childByNamePath("SPACENAME") as destination but i wanna use sth like in lucene PATH:\"/app:company_home/cm:ComTeam/cm:Customer/PROPERTIE_OF_DOCUMENT" as destination

can any1 help me please?

regards

Problem 1: On Update works fine for that, Script gets triggered after i modified properties

Problem 2: I started with following script, i get no error but it doesnt work


var Standard = document.properties["custom:AStandard"];
var Produkt = document.properties["custom:AProduktformat"];

var dest = companyhome.childByNamePath("ComTeam AG/Produktformate/" + Produkt);

document.move(dest);

cant see my mistake maybe some1???

Rule was broken, that script is working now for me:


var Produkt = document.properties["custom:AProduktformat"];
var Standard = document.properties["custom:AStandard"];
var Rahmen = document.properties["custom:ARahmen"];
var Kunde = document.properties["custom:AKunde"];
var Auftrag = document.properties["custom:AAuftrag"];

if (Standard == "Ja" && Rahmen == "Ja")
{
document.remove();
}

if (Standard == "Ja")
{
var Sziel = "ComTeam AG/Produktformate/" + Produkt;
var Sdest = companyhome.childByNamePath(Sziel);
document.move(Sdest);
}

if (Rahmen == "Ja")
{
var Rziel = "ComTeam AG/Kunden/" + Kunde + "/01 Rahmendokumente";
var Rdest = companyhome.childByNamePath(Rziel);
document.move(Rdest);
}

if (Standard == "Nein" && Rahmen == "Nein")
{
var Aziel = "ComTeam AG/Kunden/" + Kunde + "/02 Auftragsordner/" + Auftrag;
var Adest = companyhome.childByNamePath(Aziel);
document.move(Adest);
}


////// onlything i need is sth like the alert() function to make a popup with information after script execution, some1 a hint?!
2 REPLIES 2

thestorm
Champ in-the-making
Champ in-the-making
heres my final code now including my customModel.xml if some1 has a hint on sth like an alert please give it to me Smiley Happy

javascript - triggered on Update:

var Produkt = document.properties["custom:AProduktformat"];
var Struktur = document.properties["custom:AStruktur"];
var Kunde = document.properties["custom:AKunde"];
var Auftrag = document.properties["custom:AAuftrag"];
var Ressource = document.properties["custom:ARessource"];

if (Struktur == "Produktformat Vorlage")
{
var Pziel = "ComTeam AG/Produktformate/" + Produkt;
var Pdest = companyhome.childByNamePath(Pziel);
document.move(Pdest);
}

if (Struktur == "Rahmendokument")
{
var Dziel = "ComTeam AG/Kunden/" + Kunde + "/01 Rahmendokumente";
var Ddest = companyhome.childByNamePath(Dziel);
document.move(Ddest);
}

if (Struktur == "Auftragsdokument")
{
var Aziel = "ComTeam AG/Kunden/" + Kunde + "/02 Auftragsordner/" + Auftrag;
var Adest = companyhome.childByNamePath(Aziel);
document.move(Adest);
}

if (Struktur == "Ressource")
{
var Rziel = "ComTeam AG/Ressourcen/" + Ressource;
var Rdest = companyhome.childByNamePath(Rziel);
document.move(Rdest);
}

customModel.xml

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



<model name="custom:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>  
   <description>Custom Model</description>
   <author>Sebastian Danninger</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>

   <!– Introduction of new namespaces defined by this model –>
   <!– NOTE: The following namespace custom.model should be changed to reflect your own namespace –>
   <namespaces>
      <namespace uri="custom.model" prefix="custom"/>
   </namespaces>

   <constraints> 
     <constraint name="custom:Kundenliste"
       type="org.alfresco.sample.constraints.LuceneSearchBasedListConstraint" >
       <parameter name="query">
         <value> PATH:"/app:company_home/cm:ComTeam_x0020_AG/cm:Kunden/*" AND TYPE:"{http://www.alfresco.org/model/content/1.0}folder"
         </value>
       </parameter>
     </constraint>


     <constraint name="custom:Produktformate"
       type="org.alfresco.sample.constraints.LuceneSearchBasedListConstraint" >
       <parameter name="query">
         <value> PATH:"/app:company_home/cm:ComTeam_x0020_AG/cm:Produktformate/*" AND TYPE:"{http://www.alfresco.org/model/content/1.0}folder"
         </value>
       </parameter>


     </constraint>
          <constraint name="custom:Auftragsliste"
       type="org.alfresco.sample.constraints.LuceneSearchBasedListConstraint" >

   <parameter name="query">
   <value> PATH:"/app:company_home/cm:ComTeam_x0020_AG/cm:Kunden/cm:${custom:AKunde}/cm:_x0030_2_x0020_Auftragsordner//*" AND TYPE:"{http://www.alfresco.org/model/content/1.0}folder" </value>
   </parameter>
     </constraint>

     <constraint name="custom:Ressourcen"
       type="org.alfresco.sample.constraints.LuceneSearchBasedListConstraint" >
       <parameter name="query">
         <value> PATH:"/app:company_home/cm:ComTeam_x0020_AG/cm:Ressourcen/*" AND TYPE:"{http://www.alfresco.org/model/content/1.0}folder"
         </value>
       </parameter>
   </constraint>
    

   <constraint name="custom:dokumententypliste" type="LIST">
         <parameter name="allowedValues">
              <list>
                  <value>Angebot</value>
                  <value>Vertrag</value>
                  <value>Korrespondenz</value>
                  <value>Rechnung</value>
                  <value>Kundendokument</value>
                  <value>Input</value>
                  <value>Ablauf</value>
                  <value>TN Unterlagen</value>
                  <value>Präsentation / Plot</value>
                  <value>Protokoll</value>
          <value>Projektplan</value>
              </list>
         </parameter>
   </constraint>


   <constraint name="custom:struktur" type="LIST">
         <parameter name="allowedValues">
              <list>
                  <value>Rahmendokument</value>
                  <value>Auftragsdokument</value>
                  <value>Produktformat Vorlage</value>
                  <value>Ressource</value>
              </list>
         </parameter>
   </constraint>

    </constraints>

    <types>
—————
    </types>

<aspects>
        <aspect name="custom:Kunde">
                <title>Kunde</title>

                <properties>

      <!– Checkbox für Struktur –>
        <property name="custom:AStruktur">
                  <title>Rahmendokument</title>
                  <type>d:text</type>
          <mandatory>true</mandatory>
          <multiple>true</multiple>
                  <constraints>
                   <constraint ref="custom:struktur" />
                  </constraints>
                 </property>

      <!– Dokumententyp - statische Liste –>
       <property name="custom:ADokumententyp">
                 <title>Dokumententyp</title>
                 <type>d:text</type>
                 <mandatory>true</mandatory>
         <multiple>true</multiple>
                <constraints>
                 <constraint ref="custom:dokumententypliste" />
                </constraints>
                </property>

      <!– Kundenliste aus dem Space ComTeam/Kunden –>
                 <property name="custom:AKunde">
                 <title>Kunde</title>
                 <type>d:text</type>
       <default>ComTeam</default>
                 <constraints>
                  <constraint ref="custom:Kundenliste" />
                 </constraints>
                 </property>

      <!– Auftragsliste Abhängig vom Kunden –>
       <property name="custom:AAuftrag">
                 <title>Auftrag</title>
                 <type>d:text</type>
         <multiple>true</multiple>
                <constraints>
                 <constraint ref="custom:Auftragsliste" />
                </constraints>
                </property>

      <!– Produktformat Liste aus Space ComTeam/Produktformate –>
                 <property name="custom:AProduktformat">
                 <title>Produktformat</title>
                 <type>d:text</type>
       <multiple>true</multiple>
                 <index enabled="true">
                  <atomic>true</atomic>
                  <stored>false</stored>
                  <tokenised>false</tokenised>
                 </index>
                <constraints>
                 <constraint ref="custom:Produktformate" />
                </constraints>
                </property>

      <!– Ressourcenliste Abhängig vom Kunden –>
       <property name="custom:ARessource">
                 <title>Ressource</title>
                 <type>d:text</type>
         <multiple>true</multiple>
                <constraints>
                 <constraint ref="custom:Ressourcen" />
                </constraints>
                </property>

             </properties>
        </aspect>
</aspects>
</model>

jayjayecl
Confirmed Champ
Confirmed Champ
You won't get any "alert()" function since Alfresco script gets executed server-side, not client-side.

User logs instead :
http://wiki.alfresco.com/wiki/3.2_JavaScript_API#Logging_API