Having list selection bring up a second list to choose from?

Hi All,
I’m writing a script to automate filling in legal forms and have hit a wall. There is a field of check boxes (20+) of which only 1 needs to be checked on each form. I’ve figured a way to do this by only asking two questions. The first asks to select from a list of headings (case type), choosing one should cause one of four other lists to appear to ask for choices and I can’t seem to get it to work. i’m sure I’m missing something simple, but have been giving my computer very nasty looks for several hours on this one and after much searching have finally resorted to asking for help.

The display dialog at the end was just to help see the value that was returned.

Any and all help is appreciated and can lead to a cold beer the next time you’re in Vegas.

Thanks in advance.

  • Jim

set case_type to {"DOMESTIC", "MISC. DOMESTIC RELATIONS PETITIONS", "GUARDIANSHIP", "PROBATE"}

set dom_case to {"Annulment", "Divorce - No minor child(ren)", "Divorce - with minor child(ren)", "Foreign Decree", "Joint Petition - No minor child(ren)", "Joint Petition - With minor child(ren)", "Seperate Maintenance"}

set misc_case to {"Adoption - Minor", "Adoption - Adult", "Mental Health", "Name Change", "Paternity", "Permission to Marry", "Temporary Protective Order (PTO)", "Termination of Parental Rights", "Child Support/Custody", "Other"}

set guard_case to {"Guardianship of person (adult)", "Guardianship of estate (adult)", "Guardianship of person and estate (adult)", "Guardianship of person (minor)", "Guardianship of estate (minor)", "Guardianship of person and estate (minor)", "Guardianship Trust"}

set prob_case to {"Summary Administration", "General Administration", "Special Administration", "Set Aside Estates", "Trust/Conservatorships", "Individual Trustee", "Corporate Trustee", "Other Probate"}

set case_box to {choose from list case_type with prompt "Select the type of case being filed..."}

if case_box contains {"DOMESTIC"} then
	set dom_type to {choose from list dom_case with prompt "Select type of dissolution."}
else if (case_box = "MISC. DOMESTIC RELATIONS PETITIONS") then
	set misc_type to {choose from list misc_case with prompt "Select type of dissolution."}
else if (case_box = "GUARDIANSHIP") then
	set guard_type to {choose from list guard_case with prompt "Select type of dissolution."}
else if (case_box = "PROBATE") then
	set prob_type to {choose from list prob_case with prompt "Select type of dissolution."}
end if

-- display dialog to show variable chosen
display dialog "you chose " & case_box

AppleScript: 2.0.2
Browser: Safari 530.19
Operating System: Mac OS X (10.5)

Hi,

the result of choose from list in the standard form returns a list.
You have first to flatten the list


set case_type to {"DOMESTIC", "MISC. DOMESTIC RELATIONS PETITIONS", "GUARDIANSHIP", "PROBATE"}

set dom_case to {"Annulment", "Divorce - No minor child(ren)", "Divorce - with minor child(ren)", "Foreign Decree", "Joint Petition - No minor child(ren)", "Joint Petition - With minor child(ren)", "Seperate Maintenance"}

set misc_case to {"Adoption - Minor", "Adoption - Adult", "Mental Health", "Name Change", "Paternity", "Permission to Marry", "Temporary Protective Order (PTO)", "Termination of Parental Rights", "Child Support/Custody", "Other"}

set guard_case to {"Guardianship of person (adult)", "Guardianship of estate (adult)", "Guardianship of person and estate (adult)", "Guardianship of person (minor)", "Guardianship of estate (minor)", "Guardianship of person and estate (minor)", "Guardianship Trust"}

set prob_case to {"Summary Administration", "General Administration", "Special Administration", "Set Aside Estates", "Trust/Conservatorships", "Individual Trustee", "Corporate Trustee", "Other Probate"}
set case_box to {choose from list case_type with prompt "Select the type of case being filed..."} as text
if case_box is "false" then return

if case_box is "DOMESTIC" then
	set dom_type to {choose from list dom_case with prompt "Select type of dissolution."}
else if case_box = "MISC. DOMESTIC RELATIONS PETITIONS" then
	set misc_type to {choose from list misc_case with prompt "Select type of dissolution."}
else if case_box = "GUARDIANSHIP" then
	set guard_type to {choose from list guard_case with prompt "Select type of dissolution."}
else if case_box = "PROBATE" then
	set prob_type to {choose from list prob_case with prompt "Select type of dissolution."}
end if

-- display dialog to show variable chosen
display dialog "you chose " & case_box

Stefan,
You magnificent pagan GOD!!! Thank you! I can’t believe I was done in by “as text”.

I owe you one.

  • Jim

actually the braces are wrong, too. Without the text coercion the result is {{case_box}}
Better use parentheses


set case_box to (choose from list case_type with prompt "Select the type of case being filed...") as text

This is an alternative of your script


set case_type to {"1 DOMESTIC", "2 MISC. DOMESTIC RELATIONS PETITIONS", "3 GUARDIANSHIP", "4 PROBATE"}
set dom_case to {"Annulment", "Divorce - No minor child(ren)", "Divorce - with minor child(ren)", "Foreign Decree", "Joint Petition - No minor child(ren)", "Joint Petition - With minor child(ren)", "Seperate Maintenance"}
set misc_case to {"Adoption - Minor", "Adoption - Adult", "Mental Health", "Name Change", "Paternity", "Permission to Marry", "Temporary Protective Order (PTO)", "Termination of Parental Rights", "Child Support/Custody", "Other"}
set guard_case to {"Guardianship of person (adult)", "Guardianship of estate (adult)", "Guardianship of person and estate (adult)", "Guardianship of person (minor)", "Guardianship of estate (minor)", "Guardianship of person and estate (minor)", "Guardianship Trust"}
set prob_case to {"Summary Administration", "General Administration", "Special Administration", "Set Aside Estates", "Trust/Conservatorships", "Individual Trustee", "Corporate Trustee", "Other Probate"}

set caseList to {dom_case, misc_case, guard_case, prob_case}
set case_box to character 1 of ((choose from list case_type with prompt "Select the type of case being filed...") as text)
if case_box is "f" then return
set second_type to {choose from list item case_box of caseList with prompt "Select type of dissolution."}

-- display dialog to show variable chosen
display dialog "you chose " & case_box

Again, many thanks! I appreciate your help more than I can express.

you’re welcome :slight_smile: