<?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 Re: Automation Chain + setproperty + NOT mandatory Blob : Set Document BLOB properties with workflow var but got null problem in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326401#M13402</link>
    <description>&lt;P&gt;Think to check the answers that what useful for you&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jun 2013 16:40:43 GMT</pubDate>
    <dc:creator>Benjamin_Jalon1</dc:creator>
    <dc:date>2013-06-14T16:40:43Z</dc:date>
    <item>
      <title>Automation Chain + setproperty + NOT mandatory Blob : Set Document BLOB properties with workflow var but got null problem</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326397#M13398</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I want to set a Document var of type blob
with a workflow var, in an automation chain, after selection of this var in a workflow form.&lt;/P&gt;
&lt;P&gt;This workflow var is not mandatory and that is the problem.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;If I try "Update Property" but got an object is null exception and nuxeo was in a right mess.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;I try to set this variable with a condition like setting workflow var,
But nuxeo tells me that the update properties only allow "scalar"...&lt;/P&gt;
&lt;P&gt;@{WorkflowVariables["wkToto"] != null?WorkflowVariables["wkToto"]:""}&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;So I try "run script" but I couldn't get the "current document"... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;if (WorkflowVariables["wkToto"]  != null){
Document.doc.setPropertyValue("amoi:toto",WorkflowVariables["wkToto"]) ;
}&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;STRONG&gt;Do you know how to SET a document BLOB even if it's NULL with workflow var ?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2013 17:08:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326397#M13398</guid>
      <dc:creator>milonette_</dc:creator>
      <dc:date>2013-04-15T17:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Automation Chain + setproperty + NOT mandatory Blob : Set Document BLOB properties with workflow var but got null problem</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326398#M13399</link>
      <description>&lt;P&gt;Hello Me,&lt;/P&gt;
&lt;P&gt;I don't know why the basic "update property" don't work with blob...&lt;/P&gt;
&lt;P&gt;Nevertheless, this is the answer:&lt;/P&gt;
&lt;P&gt;Automation Chain:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;Document is in input.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Do A Run Script&lt;/P&gt;
&lt;P&gt;if (WorkflowVariables["varamoiwk"]  != null){
Document.doc.setPropertyValue("monxpath:mavalaupdate",WorkflowVariables["varamoiwk"]) ;
}&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Do A "Document Save" (This was missing &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; )&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;This is an exemple of an other Run Script:
&lt;A href="http://doc.nuxeo.com/pages/viewpage.action?pageId=2392665"&gt;http://doc.nuxeo.com/pages/viewpage.action?pageId=2392665&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2013 13:22:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326398#M13399</guid>
      <dc:creator>milonette_</dc:creator>
      <dc:date>2013-04-17T13:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Automation Chain + setproperty + NOT mandatory Blob : Set Document BLOB properties with workflow var but got null problem</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326399#M13400</link>
      <description>&lt;P&gt;I did a custom operation save blob from workflow to document attached to workflow in my nuxeo ide and sent it to studio&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@Operation(id=SaveBlobToInputDocument.ID, category=Constants.CAT_SERVICES, label="SaveBlobToInputDocument", description="Guarda blob en el inputdocument. Usar esta cadena solo en documentos con workflows activos")
public class SaveBlobToInputDocument {

    public static final String ID = "SaveBlobToInputDocument";
	private static final Log log = LogFactory.getLog(SaveBlobToInputDocument.class);
    @Context
	protected CoreSession session;


	@Param(name = "workflow_var", required = true)
	protected String workflowVar;

	@Param(name = "type_document", required = true)
	protected String typeDocument;
	
	@Param(name = "title_document", required = false)
	protected String titleDocument;	
	
    @Context
    protected OperationContext ctx;	

	@OperationMethod(collector = DocumentModelCollector.class)	
    public DocumentModel run(DocumentModel input) throws ClientException  {
    	if(workflowVar != null &amp;amp;&amp;amp; !workflowVar.trim().equals("")&amp;amp;&amp;amp; typeDocument!= null &amp;amp;&amp;amp; !typeDocument.trim().equals("")){
    		@SuppressWarnings("unchecked")
			Object obj =((Map&amp;lt;String, Serializable&amp;gt;)ctx.get(Constants.VAR_WORKFLOW)).get(workflowVar);          	          	
          	if (obj != null &amp;amp;&amp;amp; obj instanceof Blob){	              	
          		Blob blob= (Blob) obj;
	          	DocumentModel blobDocument = session.createDocumentModel(typeDocument);
	        	blobDocument.setPropertyValue(Constantes.XPATH_FILECONTENT,(Serializable) blob);
	        	blobDocument.setPropertyValue(Constantes.XPATH_FILENAME,(Serializable)FileUtils.getCleanFileName(blob.getFilename()));
	        	if(titleDocument != null &amp;amp;&amp;amp; !titleDocument.equals("")){
	        		blobDocument.setPropertyValue(Constantes.XPATH_TITLE, titleDocument);	
	        	}	        	
	        	try {
	    			blobDocument.setPathInfo(input.getPathAsString(),Framework.getService(PathSegmentService.class).generatePathSegment(blobDocument));
	    			session.createDocument(blobDocument);    		
	    		} catch (Exception e) {
    				throw new RuntimeException("Runtime: "+e);
	    		}
          	}
		}
    	else
    	{
    		log.warn("workflowVar o typeDocument estan vacios o nulos SaveBlobToInputDocument");
    	}
    	return input;
    }    
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jun 2013 16:02:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326399#M13400</guid>
      <dc:creator>geekonspace</dc:creator>
      <dc:date>2013-06-14T16:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Automation Chain + setproperty + NOT mandatory Blob : Set Document BLOB properties with workflow var but got null problem</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326400#M13401</link>
      <description>&lt;P&gt;thanks, that's great!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2013 16:35:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326400#M13401</guid>
      <dc:creator>milonette_</dc:creator>
      <dc:date>2013-06-14T16:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Automation Chain + setproperty + NOT mandatory Blob : Set Document BLOB properties with workflow var but got null problem</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326401#M13402</link>
      <description>&lt;P&gt;Think to check the answers that what useful for you&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2013 16:40:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326401#M13402</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2013-06-14T16:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Automation Chain + setproperty + NOT mandatory Blob : Set Document BLOB properties with workflow var but got null problem</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326402#M13403</link>
      <description>&lt;P&gt;I also would like to know when my answer has errors or if there is a better way to do that. Thanks. I only want to help&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2013 16:45:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326402#M13403</guid>
      <dc:creator>geekonspace</dc:creator>
      <dc:date>2013-06-14T16:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Automation Chain + setproperty + NOT mandatory Blob : Set Document BLOB properties with workflow var but got null problem</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326403#M13404</link>
      <description>&lt;P&gt;please create a new question for a new question.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2013 17:03:59 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/automation-chain-setproperty-not-mandatory-blob-set-document/m-p/326403#M13404</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2013-06-14T17:03:59Z</dc:date>
    </item>
  </channel>
</rss>

