<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://sugarclub.sugarcrm.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Continuation line within Dependency php file</title><link>https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/5294/continuation-line-within-dependency-php-file</link><description>I have a Dependency file using SetOptions to present a DD List. The reason I am using a Dependency file is there is more than one conditions involved so my understanding is I can&amp;#39;t build a Dependent Dropdown list within Studio as that only allows one</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Continuation line within Dependency php file</title><link>https://sugarclub.sugarcrm.com/thread/25445?ContentTypeID=1</link><pubDate>Mon, 29 Nov 2021 10:55:24 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:79a65b89-9d9e-4f00-bca3-532411362dce</guid><dc:creator>Richard Karolyi</dc:creator><description>&lt;p&gt;PHP will accept&amp;nbsp;line breaks within a string and If I&amp;#39;m not mistaken, SugarLogic&amp;nbsp;will usually ignore whitespace and newline characters, therefore&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;#39;labels&amp;#39; =&amp;gt; &amp;#39;createList(
  &amp;quot;blank&amp;quot;,
  &amp;quot;Label A&amp;quot;,
  &amp;quot;Label B&amp;quot;,
  &amp;quot;Label C&amp;quot;,
  &amp;quot;etc.&amp;quot;
&amp;#39;,
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;should work.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you&amp;nbsp;want to avoid any line breaks in&amp;nbsp;the resulting string, you&amp;nbsp;could instead concatenate separate strings using the . character:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;#39;labels&amp;#39; =&amp;gt; &amp;#39;createList(&amp;#39;
  . &amp;#39;&amp;quot;blank&amp;quot;,&amp;#39;
  . &amp;#39;&amp;quot;Label A&amp;quot;,&amp;#39;
  . &amp;#39;&amp;quot;Label B&amp;quot;,&amp;#39;
  . &amp;#39;&amp;quot;Label C&amp;quot;,&amp;#39;
  . &amp;#39;&amp;quot;etc.&amp;quot;&amp;#39;
. &amp;#39;)&amp;#39;;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;or&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;#39;labels&amp;#39; =&amp;gt; &amp;#39;createList(&amp;#39; .
  &amp;#39;&amp;quot;blank&amp;quot;,&amp;#39; .
  &amp;#39;&amp;quot;Label A&amp;quot;,&amp;#39; .
  &amp;#39;&amp;quot;Label B&amp;quot;,&amp;#39; .
  &amp;#39;&amp;quot;Label C&amp;quot;,&amp;#39; .
  &amp;#39;&amp;quot;etc.&amp;quot;&amp;#39; .
&amp;#39;)&amp;#39;;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;if you find that prettier.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuation line within Dependency php file</title><link>https://sugarclub.sugarcrm.com/thread/25393?ContentTypeID=1</link><pubDate>Wed, 17 Nov 2021 20:26:26 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:6ff8f5fd-2e01-422d-ae7d-80e12bc86bf3</guid><dc:creator>Francesca Shiekh</dc:creator><description>&lt;p&gt;One more thought, if you want to approach this in Javascript you could maintain the lists in your dropdown lists in Sugar, and just change the name of the dropdown list to load based on the other two fields.&lt;/p&gt;
&lt;p&gt;For example you have values from your dropdowns: &amp;quot;Attest&amp;quot; and &amp;quot;2020&amp;quot; you concatenate the two values and get Attest2020&lt;/p&gt;
&lt;p&gt;then in your dropdowns you define one called Attest2020 and programmatically set the dropdown values to those defined in the Attest2020 dropdown.&lt;/p&gt;
&lt;p&gt;This requires javascript coding... and I&amp;#39;ve not done it with TWO dropdowns but maybe it&amp;#39;s one way to solve it...&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;See:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://sugarclub.sugarcrm.com/explore/enterprise-professional/f/enterprise-professional-questions/5131/field-with-dependant-parent-dropdown/24845#24845"&gt;sugarclub.sugarcrm.com/.../24845&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuation line within Dependency php file</title><link>https://sugarclub.sugarcrm.com/thread/25392?ContentTypeID=1</link><pubDate>Wed, 17 Nov 2021 20:14:01 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:ca161c12-df35-44df-af8b-cb400e2a19f0</guid><dc:creator>Francesca Shiekh</dc:creator><description>&lt;p&gt;ok, I understand. As the documentation says &amp;quot;&lt;span&gt;The&amp;nbsp;&lt;/span&gt;&lt;code&gt;createList()&lt;/code&gt;&lt;span&gt;&amp;nbsp;function is a JavaScript function from Sidecar.&amp;nbsp; It requires a comma delimited quote enclosed list of options. &amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Maybe you could try something like this (I&amp;#39;ve not tried this myself so take it with a grain of salt)&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It is a bit of a different way of doing things, and possibly considered a bit of a &amp;quot;hack&amp;quot;, but it will help you keep your keys and values in a way that you can read them, and it sounds to me like these lists will be a bit of a nightmare to maintain...&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Create an array of &amp;quot;key&amp;quot;=&amp;gt;&amp;quot;value&amp;quot; pairs and then use PHP to create the comma delimited quoted lists for you.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This way you keep your key/value pairs clean and easy to read.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="php"&gt;$dropdown_array_Attest2020 = array(
  &amp;quot;19&amp;quot;=&amp;gt;&amp;quot;Label A&amp;quot;,
  &amp;quot;2&amp;quot; =&amp;gt; &amp;quot;Label B&amp;quot;,
  &amp;quot;9&amp;quot;=&amp;gt; &amp;quot;Label C&amp;quot;
);
$keys_list_Attest2020 = &amp;#39;&amp;quot;&amp;#39;. implode(&amp;#39;&amp;quot;,&amp;quot;&amp;#39;, array_keys($dropdown_array_Attest2020)). &amp;#39;&amp;quot;&amp;#39;;
$labels_list_Attest2020 =  &amp;#39;&amp;quot;&amp;#39;. implode(&amp;#39;&amp;quot;,&amp;quot;&amp;#39;, array_values($dropdown_array_Attest2020)) . &amp;#39;&amp;quot;&amp;#39;;

$dependencies[&amp;#39;RevenueLineItems&amp;#39;][&amp;#39;setoption_dep_Attest2020&amp;#39;] = array(
    &amp;#39;hooks&amp;#39; =&amp;gt; array(&amp;quot;edit&amp;quot;,&amp;quot;save&amp;quot;),
    &amp;#39;trigger&amp;#39; =&amp;gt; &amp;#39;and(equal($sym_service_line_c, &amp;quot;1&amp;quot;), equal($sym_adv_std_year_c, &amp;quot;2020&amp;quot;))&amp;#39;,
    &amp;#39;triggerFields&amp;#39; =&amp;gt; array(&amp;#39;sym_adv_std_year_c&amp;#39;, &amp;#39;sym_service_line_c&amp;#39;),
    &amp;#39;onload&amp;#39; =&amp;gt; true,
    &amp;#39;actions&amp;#39; =&amp;gt; array(
        array(
            &amp;#39;name&amp;#39; =&amp;gt; &amp;#39;SetOptions&amp;#39;,
            &amp;#39;params&amp;#39; =&amp;gt; array(
            &amp;#39;target&amp;#39; =&amp;gt; &amp;#39;fruits_c&amp;#39;,
            &amp;#39;keys&amp;#39; =&amp;gt; &amp;#39;createList({$keys_list_Attest2020})&amp;#39;,
            &amp;#39;labels&amp;#39; =&amp;gt; &amp;#39;createList({$labels_list_Attest2020})&amp;#39;
        ),
      ),
    ),
);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Let me know if this works ;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The other option is to generate the dropdown list in code, I did something similar here:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="/dev-club/f/questions-answers/2019/create-dropdown-from-module-records/7425#7425"&gt;https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/2019/create-dropdown-from-module-records/7425#7425&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In that case I would suggest that you consider building a module to maintain these options so that an admin can easily add new values, or change values,&amp;nbsp;for your dropdown without having to update the code every year.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I had a better understanding of your business need, perhaps I could suggest other solutions that are less maintenance-heavy.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;FrancescaS&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuation line within Dependency php file</title><link>https://sugarclub.sugarcrm.com/thread/25391?ContentTypeID=1</link><pubDate>Wed, 17 Nov 2021 19:04:29 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:6dec17f3-eece-4bb2-8781-dad77ba1f210</guid><dc:creator>Neil Conacher</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="/members/francescas"&gt;Francesca Shiekh&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks for responding. The Dependency will present a DD List based on options chosen on 2 other fields. The full DD List in Studio has over 100 entries and will grow over time. So the user chooses a Service Line and a Year and the Dependency file offers up an abbreviated list based on those choices.&lt;/p&gt;
&lt;p&gt;The example above is one section of the Dependency file covering one of those choice combinations - &amp;#39;only&amp;#39; 23 items in the DD list&lt;/p&gt;
&lt;p&gt;FYI, the keys list are fixed ids needed for a separate database we are integrating with - hence their apparent random order, as the labels are being presented in alphabetical order.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m trying to make the code more readable for maintenance purposes and having the 23 label options on one line is difficult to read (I&amp;#39;ve used Label A, Label B as examples. The real labels are longer)&lt;/p&gt;
&lt;p&gt;So I&amp;#39;m trying to use a line break character (I could be totally wrong in my understanding for that need) such that the Dependency file sees the Labels CreateList line as one line. I think if I put the choices on different lines without some kind of continuation indicator it doesn&amp;#39;t present the list. So I have made the assumption it does need some kind of continuation indicator and I simply tried the ; as I&amp;#39;ve seen this is some general php posts - hence my original question.&lt;/p&gt;
&lt;p&gt;Hope that makes sense.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Neil&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuation line within Dependency php file</title><link>https://sugarclub.sugarcrm.com/thread/25388?ContentTypeID=1</link><pubDate>Wed, 17 Nov 2021 14:22:13 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:ff687e1e-ec25-4417-947b-2c115460b107</guid><dc:creator>Francesca Shiekh</dc:creator><description>&lt;p&gt;I am not understanding what your dependency is trying to do, but one thing that stands out is that you added semicolons to every line in your labels list. There should not be any semicolons inside your createList regardless of how you space your elements, be it spaces or line breaks in your code.&lt;/p&gt;
&lt;p&gt;FrancescaS&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>