Alfresco: How can I check if a value already exists in DB save new values?


Alfresco In workflow form one fields values. I need to check values already exist in DB or not if exists don't save if not save different values. Is this possible?


You are saying "DB" but I will assume you mean "properties on an object stored in the Alfresco repository". If so, from JavaScript embedded in your workflow you can check a property value. If a property is named "foo:someProperty" then you can get it using doc.properties['foo:someProperty']. And you can get the object from the workflow package. All of the documents in your workflow are in an array which is accessible with bpm_package.children.

The code would look something like:

<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"> <activiti:field name="script"> <activiti:string> for (var i = 0; i &lt; bpm_package.children.length; i++) { var doc = bpm_package.children[i]; if (doc.properties['foo:someProperty'] === 'some value') { doc.properties['foo:someProperty'] = 'some other value'; doc.save(); } } </activiti:string> </activiti:field>

For more info on the Alfresco JavaScript API, see the <a href="http://docs.alfresco.com/5.1/concepts/API-JS-intro.html" rel="nofollow">docs</a>.

If you did not mean an object in the repository and you really did mean a relational database, then you'll have to implement a custom task listener using Java, and from there use JDBC or some other API to query your database and update records in the database.

If that's what you need to do, then you might take a look at this <a href="http://ecmarchitect.com/alfresco-developer-series-tutorials/workflow/tutorial/tutorial.html" rel="nofollow">workflow tutorial</a>. There is a class called ExternalReviewNotification that shows how to implement a custom task listener in Java. You could implement your own task listener that makes the JDBC call to your database.


  • Trigger Activiti workflow for task sitting in ReceiveTask looping
  • Enable CORS in Alfresco Activiti 6 (Community)
  • is there any nice way to step back in an activiti workflow task?
  • Servicemix Camel Activiti Integration and H2 Database configuration
  • Unity Static Property Injection
  • changing “with” property changes styles
  • Why do some Matlab class methods require “apparently” unnecessary output argument
  • Getting a generic method to infer the type parameter from the runtime type
  • Reading XML into Datatable gives incorrect DateTime when the time has Time Zone info
  • 'doc_del_count' bigger than 'doc_count' on CouchDB
  • c# winform DrawToBitmap offscreen
  • Changing Jupyter Notebook start up folder by modifying “start in” not working any more
  • What does “t” refer to in this SQL?
  • How to retrieve information from antrun back to maven?
  • CERN ROOT exporting data to plain text
  • where do I find the xml.dom python package for the python-2.6.0-8.9.28 and I have a suse/x86_64 vers
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • Read text file that is not in the main package in a runnable jar
  • Roxygen error “Skipping invalid path”
  • Django simple Captcha “No module named fields” error
  • How to attach a node.js readable stream to a Sendgrid email?
  • Why does access(2) check for real and not effective UID?
  • Database structure design with variable amounts of fields
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • Meteor helpers not available in Angular template
  • How do I fake an specific browser client when using Java's Net library?
  • How to get a value (ex: baseURL) in every Karate feature?
  • JSON with duplicate key names losing information when parsed
  • Build own AppleScript numerical error handling
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Benchmarking RAM performance - UWP and C#
  • Angular 2 constructor injection vs direct access
  • How to get Windows thread pool to call class member function?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Checking variable from a different class in C#
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal