Questions Tagged With ivyscripthttps://answers.axonivy.com/tags/ivyscript/?type=rss&user=Adrian%20Imfeldquestions tagged <span class="tag">ivyscript</span>enWed, 31 Jul 2019 04:33:14 -0400Elasticsearch fail because auto-conversion changes String values into Datehttps://answers.axonivy.com/questions/3903/elasticsearch-fail-because-auto-conversion-changes-string-values-into-date<p>We get an error of the Elasticsearch by saving a BusinessObject over the ivy.repo with a field of type <code>Map&lt; String,String &gt;</code>.</p> <pre><code>Elasticsearch update index of document failed because of: {"root_cause":[{"type":"illegal_argument_exception","reason":"mapper [details.data.Value1] of different type, current_type [text], merged_type [date]"}],"type":"illegal_argument_exception","reason":"mapper [details.data.Value1] of different type, current_type [text], merged_type [date]"}</code></pre> <p>The problem ist clear. The field "details.data.Value1" is a date field and i try to store a String.</p> <p><strong>But</strong> the definition of our BusinessObject is different to that!<br> The field "data" of the "detail" object is defined as a <code>Map&lt; String,String &gt;</code>.<br> We get this error when we run the following code in an IvyScript (we used a helper class for Maps, because IvyScript is not able to handle double generics).</p> <pre><code>JobDetail detail = new JobDetail(); Helper helper = new Helper(); helper.setParam("Value1", (new Date()).toString()); detail.data = helper.getParams(); job.details.add(detail); detail = new JobDetail(); helper.setParam("Value1", "foo"); detail.data = helper.getParams(); job.details.add(detail);</code></pre> <p>Why does Elasticsearch change the given attribute to a date field, although we just fill in String values?<br> Furthermore we defined the value as a Map of Sting-String value pairs.<br> Is there a solution of this issue?</p> <p>We decided not to use JSON objects instead of our Map, because of the easy handling in further uses.</p>Adrian ImfeldWed, 31 Jul 2019 04:33:14 -0400https://answers.axonivy.com/questions/3903/elasticsearch-fail-because-auto-conversion-changes-string-values-into-datebusiness-dataelasticsearchivyscriptHow to use content with contents in ScriptSteps?https://answers.axonivy.com/questions/1415/how-to-use-content-with-contents-in-scriptsteps<p>I have a Label (cms content) which holds other labels. The content of my label looks like that:</p> <pre><code>&lt;%=ivy.cms.co("/Labels/Labels/username")%&gt; or &lt;%=ivy.cms.co("/Labels/Labels/password")%&gt; is incorrect. </code></pre> <p>It works fine in JSF UI's with this code:</p> <pre><code>"#{ivy.cms.co('/Labels/Messages/loginFailedMsg')}" </code></pre> <p>But if I fill a process variable over a ScriptStep like this...</p> <pre><code>out.message = ivy.cms.co("/Labels/Messages/loginFailedMsg"); </code></pre> <p>... the integrated contents are not rendered.</p> <p>Is there a way to get the fully rendered label in a ScriptStep?</p>Adrian ImfeldTue, 28 Jul 2015 11:36:32 -0400https://answers.axonivy.com/questions/1415/how-to-use-content-with-contents-in-scriptstepsivyscriptcmsHow to work with java.util.Date in IvyScript-Step without auto initializationhttps://answers.axonivy.com/questions/52/how-to-work-with-java-util-date-in-ivyscript-step-without-auto-initialization<p>In an IvyScriptStep variables are auto initialized as soon as they are accessed. The following code will log "bad":</p> <pre><code>java.util.Date date = null; if ( date!=null) { ivy.log.info("bad"); } else { ivy.log.info("good"); } </code></pre> <p>It looks like the object "date" will never be a java.util.Date, it is an IvyDate. There is also no chance to import java.util.Date because of a conflict.</p>Adrian ImfeldWed, 06 Nov 2013 14:42:43 -0500https://answers.axonivy.com/questions/52/how-to-work-with-java-util-date-in-ivyscript-step-without-auto-initializationivyscript