<?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 Catalog Item Morpheus Variable Evaluation - Unexpected behaviour with &amp;quot;\\&amp;quot; in HPE Morpheus Enterprise Software</title>
    <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/catalog-item-morpheus-variable-evaluation-unexpected-behaviour/m-p/7251026#M4200</link>
    <description>&lt;P&gt;In Morpheus you may need to be careful when using &lt;CODE style="background : #f0f1f2;"&gt;\\&lt;/CODE&gt; within the context of Morpheus variable evaluation, as it could result in unexpected behaviour. In the future this might not be necessary, however I am writing this incase anyone else hits this behaviour. On writing this, the latest Morpheus version is 5.4.5-2.&lt;/P&gt;
&lt;P&gt;I was recently investigating an issue for a customer where &lt;CODE style="background : #f0f1f2;"&gt;&amp;lt;%= customOptions.group.split('\\|')[0] %&amp;gt;&lt;/CODE&gt; was evaluating to “1” instead of “10” when getting used within a Catalog Item where customOptions.group was equal to “10|VMware”. &lt;CODE style="background : #f0f1f2;"&gt;&amp;lt;%= customOptions.group.split('\\|')[0] %&amp;gt;&lt;/CODE&gt; was correctly evaluating to “10” elsewhere within Morpheus.&lt;/P&gt;
&lt;P&gt;When evaluating catalog item config variables, Morpheus does some preemptive escaping for certain character sets. In this case, the &lt;CODE style="background : #f0f1f2;"&gt;\\&lt;/CODE&gt; characters were being replaced with a specific charset. This was breaking the expected .split() functionality and as such, Groovy was returning each character within “10|VMware” within the returned List. Consequently, &lt;CODE style="background : #f0f1f2;"&gt;customOptions.group.split('\\|')[0]&lt;/CODE&gt; would evaluate to the ID “1”,  which was not a group available within the customers environment.&lt;/P&gt;
&lt;P&gt;For this use-case, changing &lt;CODE style="background : #f0f1f2;"&gt;.split('\\|')&lt;/CODE&gt; to &lt;CODE style="background : #f0f1f2;"&gt;.split(/[|]/)&lt;/CODE&gt; or &lt;CODE style="background : #f0f1f2;"&gt;.tokenize('|')&lt;/CODE&gt;, will avoid the escaped &lt;CODE style="background : #f0f1f2;"&gt;\\&lt;/CODE&gt; and can achieve the desired functionality for splitting the output on the &lt;CODE style="background : #f0f1f2;"&gt;|&lt;/CODE&gt; character.&lt;/P&gt;
&lt;P&gt;If you are experiencing unexpected behaviour with Variable evaluation and you are using &lt;CODE style="background : #f0f1f2;"&gt;\\&lt;/CODE&gt;, consider using a different syntax to achieve the same goal as &lt;CODE style="background : #f0f1f2;"&gt;\\&lt;/CODE&gt; may be getting replaced before the Variable is evaluated.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 27 Apr 2022 14:21:07 GMT</pubDate>
    <dc:creator>cdtaylor</dc:creator>
    <dc:date>2022-04-27T14:21:07Z</dc:date>
    <item>
      <title>Catalog Item Morpheus Variable Evaluation - Unexpected behaviour with "\\"</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/catalog-item-morpheus-variable-evaluation-unexpected-behaviour/m-p/7251026#M4200</link>
      <description>&lt;P&gt;In Morpheus you may need to be careful when using &lt;CODE style="background : #f0f1f2;"&gt;\\&lt;/CODE&gt; within the context of Morpheus variable evaluation, as it could result in unexpected behaviour. In the future this might not be necessary, however I am writing this incase anyone else hits this behaviour. On writing this, the latest Morpheus version is 5.4.5-2.&lt;/P&gt;
&lt;P&gt;I was recently investigating an issue for a customer where &lt;CODE style="background : #f0f1f2;"&gt;&amp;lt;%= customOptions.group.split('\\|')[0] %&amp;gt;&lt;/CODE&gt; was evaluating to “1” instead of “10” when getting used within a Catalog Item where customOptions.group was equal to “10|VMware”. &lt;CODE style="background : #f0f1f2;"&gt;&amp;lt;%= customOptions.group.split('\\|')[0] %&amp;gt;&lt;/CODE&gt; was correctly evaluating to “10” elsewhere within Morpheus.&lt;/P&gt;
&lt;P&gt;When evaluating catalog item config variables, Morpheus does some preemptive escaping for certain character sets. In this case, the &lt;CODE style="background : #f0f1f2;"&gt;\\&lt;/CODE&gt; characters were being replaced with a specific charset. This was breaking the expected .split() functionality and as such, Groovy was returning each character within “10|VMware” within the returned List. Consequently, &lt;CODE style="background : #f0f1f2;"&gt;customOptions.group.split('\\|')[0]&lt;/CODE&gt; would evaluate to the ID “1”,  which was not a group available within the customers environment.&lt;/P&gt;
&lt;P&gt;For this use-case, changing &lt;CODE style="background : #f0f1f2;"&gt;.split('\\|')&lt;/CODE&gt; to &lt;CODE style="background : #f0f1f2;"&gt;.split(/[|]/)&lt;/CODE&gt; or &lt;CODE style="background : #f0f1f2;"&gt;.tokenize('|')&lt;/CODE&gt;, will avoid the escaped &lt;CODE style="background : #f0f1f2;"&gt;\\&lt;/CODE&gt; and can achieve the desired functionality for splitting the output on the &lt;CODE style="background : #f0f1f2;"&gt;|&lt;/CODE&gt; character.&lt;/P&gt;
&lt;P&gt;If you are experiencing unexpected behaviour with Variable evaluation and you are using &lt;CODE style="background : #f0f1f2;"&gt;\\&lt;/CODE&gt;, consider using a different syntax to achieve the same goal as &lt;CODE style="background : #f0f1f2;"&gt;\\&lt;/CODE&gt; may be getting replaced before the Variable is evaluated.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 14:21:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise-software/catalog-item-morpheus-variable-evaluation-unexpected-behaviour/m-p/7251026#M4200</guid>
      <dc:creator>cdtaylor</dc:creator>
      <dc:date>2022-04-27T14:21:07Z</dc:date>
    </item>
  </channel>
</rss>

