<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic script to execute on content rule - add metadata in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/script-to-execute-on-content-rule-add-metadata/m-p/257282#M210412</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am attempting to write a (java)script that will execute on a content rule - specifically, to add some required metadata to a record within a Records Mgmt site.&amp;nbsp; I think I've managed to find the model definitions… in recordsModel.xml (and maybe recordsCustomModel.xml?)….&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rma&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://connect.hyland.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;riginatingOrganzation&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rma&lt;img id="smileytongue" class="emoticon emoticon-smileytongue" src="https://connect.hyland.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;ublicationDate&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rma&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://connect.hyland.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;riginator&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And so tried the code below, cribbed a bit from another example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;// doc.properties["my:prop1"] = "new constant value";&lt;BR /&gt;// doc.properties["my:prop2"] = "new other constant value"';&lt;BR /&gt;doc.properties["rma:originator"] = "John Q. Author";&lt;BR /&gt;doc.properties["rma:originationOrganization"] = "SomeCO Limited Inc.";&lt;BR /&gt;doc.properties["rma:publicationDate"] = "Fri Feb 04 01:00:00 EST 2011";&lt;BR /&gt;/* more stuff */&lt;BR /&gt;doc.save();&amp;nbsp; /* to save the properties just set *&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when I try to upload a record, and this rule files, it fails, and the catalina.out logs this:&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;"22:28:40,403 User:gnyce ERROR [extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 01040963 Failed to execute script 'workspace://SpacesStore/6376f7ac-4516-4809-8db3-94b08bb32cab':&lt;BR /&gt; 01040962 ReferenceError: "doc" is not defined. (workspace://SpacesStore/6376f7ac-4516-4809-8db3-94b08bb32cab#3)&lt;BR /&gt;org.alfresco.scripts.ScriptException: 01040963 Failed to execute script 'workspace://SpacesStore/6376f7ac-4516-4809-8d&lt;BR /&gt;b3-94b08bb32cab': 01040962 ReferenceError: "doc" is not defined. (workspace://SpacesStore/6376f7ac-4516-4809-8db3-94b0&lt;BR /&gt;8bb32cab#3)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:244)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:195)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;BR /&gt;&amp;lt;SNIP&amp;gt;&lt;BR /&gt;Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "doc" is not defined. (workspace://SpacesStore/6376f7ac-4516-4809-8db3-94b08bb32cab#3)"&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Which seems to indicate that I need to, in the script, somehow refer to or provide a handle to the uploaded record.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Questions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. how do I, in javascript, specify the document being uploaded?&amp;nbsp; Is that setting a javascript variable via the document spacestore ID?&amp;nbsp; How do I get that (upon the doc being uploaded?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. how do I find the nomenclature of RM custom fields added?&amp;nbsp; I'll need a handle to be able to set metadata on them. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not a developer at all, so am stumbling around quite a bit - feels like I've made a little progress, but hoping for some pointer(s).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 05 Feb 2011 17:46:33 GMT</pubDate>
    <dc:creator>gnyce</dc:creator>
    <dc:date>2011-02-05T17:46:33Z</dc:date>
    <item>
      <title>script to execute on content rule - add metadata</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/script-to-execute-on-content-rule-add-metadata/m-p/257282#M210412</link>
      <description>I am attempting to write a (java)script that will execute on a content rule - specifically, to add some required metadata to a record within a Records Mgmt site.&amp;nbsp; I think I've managed to find the model definitions… in recordsModel.xml (and maybe recordsCustomModel.xml?)….rma&lt;IMG id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;riginatingOrganzationrm</description>
      <pubDate>Sat, 05 Feb 2011 17:46:33 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/script-to-execute-on-content-rule-add-metadata/m-p/257282#M210412</guid>
      <dc:creator>gnyce</dc:creator>
      <dc:date>2011-02-05T17:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: script to execute on content rule - add metadata</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/script-to-execute-on-content-rule-add-metadata/m-p/257283#M210413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, got originator and originatingOrganization working.&amp;nbsp; Currently stuck on setting the date - what format it wants, etc.&amp;nbsp; Once I get that figured out, will work on the custom metadata field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Caused by: org.alfresco.service.cmr.repository.datatype.TypeConversionException: The property value is not compatible &lt;BR /&gt;with the type defined for the property: &lt;BR /&gt;&amp;nbsp;&amp;nbsp; property: Name: {&lt;A href="http://www.alfresco.org/model/recordsmanagement/1.0}publicationDateTitle" rel="nofollow noopener noreferrer"&gt;http://www.alfresco.org/model/recordsmanagement/1.0}publicationDateTitle&lt;/A&gt;: Publication Date&lt;BR /&gt;Description: null&lt;BR /&gt;Default Value: null&lt;BR /&gt;DataType Name: {&lt;A href="http://www.alfresco.org/model/dictionary/1.0}date" rel="nofollow noopener noreferrer"&gt;http://www.alfresco.org/model/dictionary/1.0}date&lt;/A&gt;&lt;BR /&gt;ContainerClass Name: {&lt;A href="http://www.alfresco.org/model/recordsmanagement/1.0}record" rel="nofollow noopener noreferrer"&gt;http://www.alfresco.org/model/recordsmanagement/1.0}record&lt;/A&gt;&lt;BR /&gt;isMultiValued: false&lt;BR /&gt;isMandatory: true&lt;BR /&gt;isMandatoryEnforced: falseisProtected: false&lt;BR /&gt;isIndexed: true&lt;BR /&gt;isStoredInIndex: false&lt;BR /&gt;isIndexedAtomically: true&lt;BR /&gt;indexTokenisationMode: TRUE&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; value: 2011020400:00:00&lt;BR /&gt;&amp;nbsp;&amp;nbsp; value type: class java.lang.String&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Feb 2011 03:27:09 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/script-to-execute-on-content-rule-add-metadata/m-p/257283#M210413</guid>
      <dc:creator>gnyce</dc:creator>
      <dc:date>2011-02-06T03:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: script to execute on content rule - add metadata</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/script-to-execute-on-content-rule-add-metadata/m-p/257284#M210414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Punted on the date - just set it to be the same as created value.&amp;nbsp; Now to figure out how to address/refer-to the custom metadata field (already setup within the RM Console).&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;//set variable to be the created value, then set values&lt;BR /&gt;var PubDate = document.properties["cm:created"];&lt;BR /&gt;document.properties["rma:originator"] = "John Q. Originator";&lt;BR /&gt;document.properties["rma:originatingOrganization"] = "SOMECO Company Ltd Inc";&lt;BR /&gt;document.properties["rma:publicationDate"] = PubDate;&lt;BR /&gt;document.save();&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Feb 2011 04:26:26 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/script-to-execute-on-content-rule-add-metadata/m-p/257284#M210414</guid>
      <dc:creator>gnyce</dc:creator>
      <dc:date>2011-02-06T04:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: script to execute on content rule - add metadata</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/script-to-execute-on-content-rule-add-metadata/m-p/257285#M210415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Got it - looking at the RecordsCustomModel.xml, seemed like I could refer to the custom field by using "rmc:NameOfMyCustomField", and it worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;document.properties["rmc:MyCustomFieldNameHere"] = "Fill in field with this metadata";&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Feb 2011 05:10:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/script-to-execute-on-content-rule-add-metadata/m-p/257285#M210415</guid>
      <dc:creator>gnyce</dc:creator>
      <dc:date>2011-02-06T05:10:51Z</dc:date>
    </item>
  </channel>
</rss>

