<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.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>Trying to set a default value in a Custom Data Type which will load in a DropDown Box for a Process Start Form.</title><link>https://community.appian.com/discussions/f/general/18696/trying-to-set-a-default-value-in-a-custom-data-type-which-will-load-in-a-dropdown-box-for-a-process-start-form</link><description>Hey Appian Community! 
 First time post, please forgive my newbness! 
 Trying to set a default value in a Process Start Form which will essentially save the user having to select a default value when the screen loads. 
 I was able to do it when I use</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Trying to set a default value in a Custom Data Type which will load in a DropDown Box for a Process Start Form.</title><link>https://community.appian.com/thread/73654?ContentTypeID=1</link><pubDate>Tue, 28 Apr 2020 15:06:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:69e4a1c5-eac6-4063-9eda-eed0dd0ad169</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="48433" url="~/discussions/f/general/18696/trying-to-set-a-default-value-in-a-custom-data-type-which-will-load-in-a-dropdown-box-for-a-process-start-form/73648"]Is it normal to have to wrap the whole formLayout code into the local variables domain/function[/quote]
&lt;p&gt;Yes, that&amp;#39;s exactly how it works.&amp;nbsp; You can also wrap individual components/sections/etc in their own localvariables call, for variables that will only be used in the scope of that section/etc.&amp;nbsp; These can be nested as needed, though the easiest way to manage variables for a general use case is to have at least one at the top level of the form.&amp;nbsp; When I start a new form I usually include the wrapper at the top level even if I don&amp;#39;t need any yet, under the assumption that I eventually will.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to set a default value in a Custom Data Type which will load in a DropDown Box for a Process Start Form.</title><link>https://community.appian.com/thread/73648?ContentTypeID=1</link><pubDate>Tue, 28 Apr 2020 13:49:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:95b19121-d457-47f2-a5b9-4f1740aa1d17</guid><dc:creator>LTSmash</dc:creator><description>&lt;p&gt;Also got the local variable going. Thanks again Mike, legend!&lt;/p&gt;
&lt;p&gt;Is it normal to have to wrap the whole formLayout code into the local variables domain/function - is that best practice?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to set a default value in a Custom Data Type which will load in a DropDown Box for a Process Start Form.</title><link>https://community.appian.com/thread/73645?ContentTypeID=1</link><pubDate>Tue, 28 Apr 2020 12:53:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4da6a311-b4dd-47c1-8b6d-dac1232c9f01</guid><dc:creator>LTSmash</dc:creator><description>&lt;p&gt;Amazing, thank-you Mike.&lt;/p&gt;
&lt;p&gt;Got the first method going by doing just as you said. For the folks watching at home:&lt;/p&gt;
&lt;p&gt;- Used an IF Statement in the &amp;#39;value&amp;#39; checking for NULL for the drop down field&lt;/p&gt;
&lt;p&gt;- Used an IF Statement in the Save Into checking for NULL and saving the variable.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;PS: Getting more accustomed to the &amp;#39;expression mode&amp;#39; definitely is easier once you know the domain names. Will be trying out the local variable method now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to set a default value in a Custom Data Type which will load in a DropDown Box for a Process Start Form.</title><link>https://community.appian.com/thread/73637?ContentTypeID=1</link><pubDate>Tue, 28 Apr 2020 02:40:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d82c487a-13f5-49d8-b0de-f3526bcc8ca8</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;ol&gt;
&lt;li&gt;&amp;quot;placeholder label&amp;quot; is the default text readout (to serve as a prompt to the user) that will render in a dropdown when&amp;nbsp;&lt;em&gt;no value&lt;/em&gt; is selected - i usually put something like &amp;quot;--choose a condition--&amp;quot;.&amp;nbsp; You&amp;#39;ve set it to &amp;quot;New&amp;quot; which is just one of the conditions, which is not the intent of this setting.
&lt;ol&gt;
&lt;li&gt;I think for this you mistook what I was trying to say.&amp;nbsp; You would actually set the&amp;nbsp;&lt;strong&gt;value&lt;/strong&gt; parameter to an expression which conditionally checks the nullicity of the target&amp;nbsp;&lt;em&gt;&lt;strong&gt;ri!CDT_bikes.condition&lt;/strong&gt;&lt;/em&gt;&lt;em&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/em&gt; and uses the value of &amp;quot;New&amp;quot; when it&amp;#39;s null.&amp;nbsp; In your top screenshot the target for this would be the &amp;quot;selected value&amp;quot; configuraton field, which you&amp;#39;d need to fill with an expression.&lt;/li&gt;
&lt;li&gt;as a side note, I strongly urge you to get used to looking at the &amp;quot;expression mode&amp;quot; code, because after the skeleton framework of your interface is set up initially, editing the code directly is easier &lt;strong&gt;by far.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;for the second version, your code is missing the required&amp;nbsp;&lt;em&gt;&lt;strong&gt;a!save()&lt;/strong&gt;&lt;/em&gt; command which is the only thing that actually causes a custom save to be executed.&amp;nbsp; For brevity I&amp;#39;ll just try to write what I think your code should be:&lt;br /&gt;&lt;pre class="ui-code" data-mode="java"&gt;if(
  isnull(ri!LTPD_CDT_Bikes.condition),
  a!save(
    ri!LTPD_CDT_Bikes.condition, /* &amp;lt;---- this is the save target */
    cons!LTPD_CONS_CONDITION_BIKE[1] /* &amp;lt;---- this is the save VALUE */
  ),
  {}  /* &amp;lt;---- if bikes.condition was NOT null, then we do NOT want to execute a save here. */
)&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to set a default value in a Custom Data Type which will load in a DropDown Box for a Process Start Form.</title><link>https://community.appian.com/thread/73636?ContentTypeID=1</link><pubDate>Tue, 28 Apr 2020 01:05:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:858f194d-4494-42f7-8a44-a7aedcee917c</guid><dc:creator>LTSmash</dc:creator><description>&lt;p&gt;Hey Mike!&lt;/p&gt;
&lt;p&gt;As I&amp;#39;m learning, I want to be able to try and test both examples. For the first one I&amp;#39;m now receiving a new error.&lt;/p&gt;
&lt;p&gt;Not sure what I&amp;#39;ve done wrong here. Is it tripping up on the Constant - not sure why that wouldn&amp;#39;t work right as it exists in the interface.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/02-Default-Label.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/03-Check-for-Null-at-Submit.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to set a default value in a Custom Data Type which will load in a DropDown Box for a Process Start Form.</title><link>https://community.appian.com/thread/73604?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 14:42:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f35df41d-aa22-4e46-b5b5-61841e2defca</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Please note (in case I wasn&amp;#39;t clear originally) that my 2 bullet points above are mutually exclusive solutions.&amp;nbsp; It&amp;#39;s just one or the other.&lt;/p&gt;
&lt;p&gt;For point 1, yes you basically have it - you would show the default value in the field on the form, but the CDT rule input would *not* contain this default value unless through manual user interaction, so during form submission, you would check whether this value is blank and if so, save the desired default value &lt;strong&gt;into&lt;/strong&gt; it at that point.&lt;/p&gt;
&lt;p&gt;For point 2: you&amp;#39;re confusing &amp;quot;local variable&amp;quot; with &amp;quot;process variable&amp;quot; which are completely separate things.&amp;nbsp; On a start form you do not have process variables in the equation - all it sees are local variables declared in your SAIL form, and rule input variables.&amp;nbsp; Nothing in the process model comes into play until the form is submitted.&amp;nbsp; So what I was describing, is that you would define a&amp;nbsp;&lt;strong&gt;&lt;em&gt;local variable&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;&lt;/em&gt; within your form itself, to hold the contents you&amp;nbsp;&lt;em&gt;eventually&lt;/em&gt; intend to pass into your process instance (i.e. your CDT_Bikes pv).&amp;nbsp; All fields of your form would save their values into this local variable instead of into the rule input, and then you would save the&amp;nbsp;&lt;strong&gt;whole&lt;/strong&gt; local variable directly into the Rule Input when submitting the form.&lt;/p&gt;
&lt;p&gt;Take this mini example of case 2:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  
  local!bikes: {
    id: null(),
    numWheels: 2,
    bodyType: null()
  },
  
  a!formLayout(
    label: &amp;quot;Add Bike&amp;quot;,
    contents: {
      a!dropdownField(
        label: &amp;quot;Number of Wheels&amp;quot;,
        placeholderLabel: &amp;quot;--select wheel count--&amp;quot;,
        choiceValues: {2, 3},
        choiceLabels: {&amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;},
        value: local!bikes.numWheels,
        saveInto: local!bikes.numWheels
      ),
      a!textField(
        label: &amp;quot;Body Type&amp;quot;,
        value: local!bikes.bodyType,
        saveInto: local!bikes.bodyType,
        required: true()
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          submit: true(),
          label: &amp;quot;Submit&amp;quot;,
          saveInto: {
            a!save(
              ri!bikes,
              local!bikes
            )
          }
        )
      }
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to set a default value in a Custom Data Type which will load in a DropDown Box for a Process Start Form.</title><link>https://community.appian.com/thread/73602?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 14:30:11 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3beace39-2b45-4aa3-af9b-2c774d99573b</guid><dc:creator>LTSmash</dc:creator><description>&lt;p&gt;Hey Mike,&lt;/p&gt;
&lt;p&gt;Thanks for responding so quickly.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;For point 1: So for the value should I use an expression, something along the lines of:&lt;/p&gt;
&lt;p&gt;If (null) then show &amp;quot;default_value&amp;quot;.&lt;/p&gt;
&lt;p&gt;Then in the SaveInto (in Submit) do the same?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If (null) then show &amp;quot;default_value&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For Point 2: The variable is essentially a text type in the CDT. So should I pass a local Process variable (with the default value) into the form and then set that value in the form?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I don&amp;#39;t quite understand what you mean by subsequent fields would also save their changes.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Appreciate your response! Cheers!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to set a default value in a Custom Data Type which will load in a DropDown Box for a Process Start Form.</title><link>https://community.appian.com/thread/73600?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 14:20:34 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:02e2cf41-7dc5-4bb7-a786-81bac5e515cc</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;You can&amp;#39;t do this via the process model for use with a start form - when the user is seeing a start form, no instance of the process even exists yet -- the way you should think of it is, the *results* of a successfully submitted start form are then passed into a new process instance at time of submission.&lt;/p&gt;
&lt;p&gt;To handle this you&amp;#39;ll need to do it on your SAIL form itself.&amp;nbsp; There are various techniques and none of them are perfect, but many that will at least do what you want.&amp;nbsp; The one you choose depends largely on whether any subsequent form inputs or choices depend at all on the value of the selection you want to show a default version for.&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If there isn&amp;#39;t anything on the form that depends on it, then you can simply make the selection field in question check for a null value and display your default selection when null, then in the SaveInto section of the Submit button, you would need to save the default value desired (if the original value is still null) into the proper field within the CDT in the Rule Inputs.&lt;/li&gt;
&lt;li&gt;An alternative approach is to define a local variable with the CDT&amp;#39;s type, where you can manually set the value up-front for the field in question to whatever your preferred default value is; then subsequent fields in the form would also save their changes into this local variable; and then on the Submit button you would save the whole local variable into the relevant Rule Input.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>