How can I set a default value for a smart dropdown which depends on the value of another dropdown?

Kathleen Janiszewski July 12, 2023

I have a form where the user enters a Fiscal Year.  The Fiscal Year is a normal dropdown.  From that, the Start Week and End Week are populated with data from the Weeks ConfiForm - both are smart dropdowns, and work just fine.  There are some instances where no Start Week or End Week are necessary.  When these are left empty, the IFTTT macro will no execute.  I've removed all associated rules, so I know it's not the rules on the Start Week or End Week fields.  Therefore, I would like a way to set the default Start Week and End Week.

1 answer

0 votes
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2023

Hi

Not entirely understand your question, but you can set values to any fields in ConfiForms, including smart fields - best option is to use the "Lookup and set" rule - https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-Lookupandsetvalue

And this way you can see what rules get executed and in which order https://wiki.vertuna.com/display/CONFIFORMS/How+to+troubleshoot+and+debug+ConfiForms+IFTTT+rules+execution

Alex

Kathleen Janiszewski July 12, 2023

Alex,

I would set the default Start Week to either this week, if it's the current fiscal year, or 1 if it is in the future.  The End Week should be the last entry, wither week 52 or 53, depending on how many are in the Fiscal Year.  I don't need them at all for type "Other", and I have a rule that hides the bottom fields.  Right now, if I enter all of the data, but don't select a Start Week or End Week, my onCreated IFTTT macro will not execute.

startweek and endweek issue.PNG

The start week and end week are both Smart dropdowns and get their data from the Weeks Table:

startweek field definiton.PNG

The following is some of the data from the weeks table:

weeks confiform.PNG
I'd like to set default dates, but they aren't required for all types.  I *do* however always need the onCreated IFTTT macro to execute.  Right now, it will only execute if dates are selected in the smart dropdowns.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2023

Hi

If I understand you correctly then this is something you can do (smart fields expect the ID (UUID) as a value, as all they hold is a reference to another record)

http://recordit.co/oB7cYgrbqZ

With a complete example as a storage format for easier import using Confluence source editor

<ac:structured-macro ac:macro-id="08f8d8d7-8d95-4526-8bf9-6024699c787a" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">weeks</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="46975374-4df7-422c-bd73-2cc2c3bf05ac" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="type">Embedded</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="9221e074-a493-464f-9a75-4e253711756c" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">year</ac:parameter>
<ac:parameter ac:name="fieldLabel">year</ac:parameter>
<ac:parameter ac:name="type">number</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="3e23c979-144a-4b1f-8e1b-4bc55fa53a9d" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">weekNumber</ac:parameter>
<ac:parameter ac:name="fieldLabel">week Number</ac:parameter>
<ac:parameter ac:name="type">number</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>weeks</p>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="df788182-97a0-4e34-89b6-de69d67264c8" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">weeks</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="19ff4b57-9ee2-4d0f-8537-a8d63a4cb27a" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">using</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="ee596c9c-1474-4bd6-98d1-99b2741eb8a8" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">year</ac:parameter>
<ac:parameter ac:name="fieldLabel">year</ac:parameter>
<ac:parameter ac:name="type">number</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="aaa351ae-460a-4c37-afc9-d846a1d4c63c" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="fieldName">startWeek=[entry.id]</ac:parameter>
<ac:parameter ac:name="values">year:[entry.year]</ac:parameter>
<ac:parameter ac:name="action">Lookup and set value</ac:parameter>
<ac:parameter ac:name="onUserActionOnly">true</ac:parameter>
<ac:parameter ac:name="actionFieldName">year</ac:parameter>
<ac:parameter ac:name="values2">weeks</ac:parameter>
<ac:parameter ac:name="values3">weekNumber ASC LIMIT 1</ac:parameter>
</ac:structured-macro> </p>
<p>
<ac:structured-macro ac:macro-id="0de6c317-aab0-4171-87ea-87ee07f2d129" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="fieldName">endWeek=[entry.id]</ac:parameter>
<ac:parameter ac:name="values">year:[entry.year]</ac:parameter>
<ac:parameter ac:name="action">Lookup and set value</ac:parameter>
<ac:parameter ac:name="onUserActionOnly">true</ac:parameter>
<ac:parameter ac:name="actionFieldName">year</ac:parameter>
<ac:parameter ac:name="values2">weeks</ac:parameter>
<ac:parameter ac:name="values3">weekNumber DESC LIMIT 1</ac:parameter>
</ac:structured-macro> </p>
<p>
<ac:structured-macro ac:macro-id="f3175436-9bf7-4931-a310-a287782ed5c2" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">startWeek</ac:parameter>
<ac:parameter ac:name="fieldLabel">start week</ac:parameter>
<ac:parameter ac:name="values">[148111498|weeks|weekNumber|true||]</ac:parameter>
<ac:parameter ac:name="type">smartselect</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="8640ef29-1edf-41cb-a1c6-77e8caef4925" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">endWeek</ac:parameter>
<ac:parameter ac:name="fieldLabel">end week</ac:parameter>
<ac:parameter ac:name="values">[148111498|weeks|weekNumber|true||]</ac:parameter>
<ac:parameter ac:name="type">smartselect</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="d6ecc6f3-3818-4163-aec6-f114d94b0031" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="type">Embedded</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>

Hope it helps

Alex

Like Kathleen Janiszewski likes this
Kathleen Janiszewski July 18, 2023

Alex,

This appears to work to set the defaults, so that helps!

I like what you did to get the first and last week by using ASC and DESC, but how do I to the default to a certain week, like the current week?  Also I want to give the option of "None" with a weekNumber of 0, zero.

Thank you in advance.

-Kathleen

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2023

Hi

You can use the following rules instead (of the 2 in my previous example)

 <p>
<ac:structured-macro ac:macro-id="83f1c5cd-e6a7-4b93-b079-7d795cf3f2b0" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">!year:[entry._now.formatDate(yyyy)]</ac:parameter>
<ac:parameter ac:name="fieldName">startWeek=[entry.id]</ac:parameter>
<ac:parameter ac:name="values">year:[entry.year]</ac:parameter>
<ac:parameter ac:name="action">Lookup and set value</ac:parameter>
<ac:parameter ac:name="onUserActionOnly">true</ac:parameter>
<ac:parameter ac:name="actionFieldName">year</ac:parameter>
<ac:parameter ac:name="values2">weeks</ac:parameter>
<ac:parameter ac:name="values3">weekNumber ASC LIMIT 1</ac:parameter>
</ac:structured-macro> <ac:structured-macro ac:macro-id="f370c014-ada3-46bc-95b0-538990a96712" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">year:[entry._now.formatDate(yyyy)]</ac:parameter>
<ac:parameter ac:name="fieldName">startWeek=[entry.id]</ac:parameter>
<ac:parameter ac:name="values">year:[entry.year] AND weekNumber:[entry._now.formatDate(w)]</ac:parameter>
<ac:parameter ac:name="action">Lookup and set value</ac:parameter>
<ac:parameter ac:name="onUserActionOnly">true</ac:parameter>
<ac:parameter ac:name="actionFieldName">year</ac:parameter>
<ac:parameter ac:name="values2">weeks</ac:parameter>
<ac:parameter ac:name="values3">weekNumber ASC LIMIT 1</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="0de6c317-aab0-4171-87ea-87ee07f2d129" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="fieldName">endWeek=[entry.id]</ac:parameter>
<ac:parameter ac:name="values">year:[entry.year]</ac:parameter>
<ac:parameter ac:name="action">Lookup and set value</ac:parameter>
<ac:parameter ac:name="onUserActionOnly">true</ac:parameter>
<ac:parameter ac:name="actionFieldName">year</ac:parameter>
<ac:parameter ac:name="values2">weeks</ac:parameter>
<ac:parameter ac:name="values3">weekNumber DESC LIMIT 1</ac:parameter>
</ac:structured-macro>
</p>

PS, not sure I get the question about the "None" case

Alex

Like Kathleen Janiszewski likes this
Kathleen Janiszewski July 19, 2023

Alex,

Thank you once again!

The "None" option was recommended by my colleague in the case the customer has an "Other" expense type, typically some kind of fee.  In that case, the start week, end week, and weekly hours are hidden, because they aren't needed.  Putting default values in there is fine, but they don't really make sense.  Like I've said before, the user was able to do these things in Excel, and they want to be able to do things the same way. Since they are required in some cases, and not in others, it becomes complicated.  It would be more elegant to make them required/optional based on userType, but it's easier to program if I simply ignore it.

Thank you again!

-Kathleen

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events