Content Management and Capture

 View Only
  • 1.  Jscript for Property Template copy

    Posted Wed October 07, 2020 11:39 AM
    I have an Object Store where we need to merge two property templates into one.  Easiest way I can find to do it is use a Batch Action in ACCE and run a Jscript to copy one property's string into another property's string.  I'm not familier with Java Scripting enough to know the code and wondered if someone out there has done this already and would be up for sharing that?  Both Property Templates are string.

    ------------------------------
    David Powell
    ------------------------------


  • 2.  RE: Jscript for Property Template copy

    Posted Thu October 08, 2020 08:47 AM

    You could try this.  Replace the symbolic names of the properties with the ones you want.  Test it on a single object first, then try it on more as needed.  It would be quicker in execution to write some code that did this in a batch.  I've added some comments to explain what the code is doing.  I tend to assemble these from a pool of smaller functions as needed.

    importPackage(java.lang); importPackage(Packages.com.filenet.api.property); importPackage(Packages.com.filenet.api.core); importPackage(Packages.com.filenet.api.constants); function OnCustomProcess (CEObject) { // Replace the <value> with the true symbolic names of the properties var sourceSymbolicName = "<sourcePropertySymbolicName>"; var targetSymbolicName = "<targetPropertySymbolicName>"; // ensure that the source value is available for the object. Fetch as many as are neede by making more entries in the array // CEObject.fetchProperties([sourceSymbolicName, "other property symbolicname", "another", "and another"]); CEObject.fetchProperties([sourceSymbolicName]); // call this as many times with whichever names you want. make sure they're fetched before you try are retrieve them updateProperty(CEObject, sourceSymbolicName, targetSymbolicName); // update the object, no need to refresh as you're just updating them and don't care what the new result is CEObject.save(RefreshMode.NO_REFRESH); } // a simple function to update a property with the value of another. No checking of type or content is done here. The CE will do that and fail if incorrect function updateProperty(CEObject, sourceSymbolicName, targetSymbolicName) { var sourceValue = CEObject.getProperties().getStringValue(sourceSymbolicName); CEObject.getProperties().putValue(targetSymbolicName, sourceValue); } ​


  • 3.  RE: Jscript for Property Template copy

    Posted Thu October 08, 2020 10:50 AM
    This worked perfectly!  Thank you David for your assistance.  this saved me a ton of time and work.

    ------------------------------
    David Powell
    ------------------------------



  • 4.  RE: Jscript for Property Template copy

    Posted Thu October 08, 2020 11:58 AM
    David,

    Yes, we have done similar work before in P8. This is a quick fix, only a few hrs of coding work assuming this isn't millions of documents.

    My email is below if you'd like to reach out and have a conversation w/ myself and our VP of Services. 

    cweis@DASpartner.com


    Happy to help!

    Bests,
    Cam

    ------------------------------
    Camden Weis
    Director of Sales
    DAS, an IBM Gold Business Partner
    ------------------------------