Hi all,
Some background on my problem:
I have a form that accepts some values from keyboard input pictured below.
The form section values are named "Non_Discountable_1" and "Non_Discountable_1_Quantity" from 1-10.
The left field is a multi option dropdown, and the right field is a int.
The multi field drop down is populated by a script on form load, because I want the ability to change values later without having to adjust the form.
Here is how I set the dropdown values through a workflow when the form is loaded:
- //SET non discountable
- demoPricebook = Collection();
- demoPricebook = thisapp.returnPriceBook("demoPricebook");
- keyList = List();
- keyList = demoPricebook.keys();
- clear Non_Discountable_1;
- clear Non_Discountable_2;
- clear Non_Discountable_3;
- clear Non_Discountable_4;
- clear Non_Discountable_5;
- clear Non_Discountable_6;
- clear Non_Discountable_7;
- clear Non_Discountable_8;
- clear Non_Discountable_9;
- clear Non_Discountable_10;
- for each index indexNum in keyList
- {
- input.Non_Discountable_1:ui.append(keyList.get(indexNum));
- input.Non_Discountable_2:ui.append(keyList.get(indexNum));
- input.Non_Discountable_3:ui.append(keyList.get(indexNum));
- input.Non_Discountable_4:ui.append(keyList.get(indexNum));
- input.Non_Discountable_5:ui.append(keyList.get(indexNum));
- input.Non_Discountable_6:ui.append(keyList.get(indexNum));
- input.Non_Discountable_7:ui.append(keyList.get(indexNum));
- input.Non_Discountable_8:ui.append(keyList.get(indexNum));
- input.Non_Discountable_9:ui.append(keyList.get(indexNum));
- input.Non_Discountable_10:ui.append(keyList.get(indexNum));
- }
Once the values are chosen and form is submitted, I am attempting to access these field selections from a ZML script with deluge deluge and display them on said sales page.
Here is an excerpt of the script from the ZML on the sales page that defines the List that contains the elements from the form fields.
- //ASSIGN DEMO AND ETC
- nonDCItems = List();
- if(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_1_Quantity > 0 && Quote_Builder[ID == input.firstQuoteID].Non_Discountable_1_Quantity != null)
- {
- nonDCItems.add(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_1);
- }
- if(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_2_Quantity > 0 && Quote_Builder[ID == input.firstQuoteID].Non_Discountable_2_Quantity != null)
- {
- nonDCItems.add(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_2);
- }
- if(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_3_Quantity > 0 && Quote_Builder[ID == input.firstQuoteID].Non_Discountable_3_Quantity != null)
- {
- nonDCItems.add(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_3);
- }
- if(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_4_Quantity > 0 && Quote_Builder[ID == input.firstQuoteID].Non_Discountable_4_Quantity != null)
- {
- nonDCItems.add(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_4);
- }
- if(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_5_Quantity > 0 && Quote_Builder[ID == input.firstQuoteID].Non_Discountable_5_Quantity != null)
- {
- nonDCItems.add(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_5);
- }
- if(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_6_Quantity > 0 && Quote_Builder[ID == input.firstQuoteID].Non_Discountable_6_Quantity != null)
- {
- nonDCItems.add(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_6);
- }
- if(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_7_Quantity > 0 && Quote_Builder[ID == input.firstQuoteID].Non_Discountable_7_Quantity != null)
- {
- nonDCItems.add(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_7);
- }
- if(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_8_Quantity > 0 && Quote_Builder[ID == input.firstQuoteID].Non_Discountable_8_Quantity != null)
- {
- nonDCItems.add(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_8);
- }
- if(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_9_Quantity > 0 && Quote_Builder[ID == input.firstQuoteID].Non_Discountable_9_Quantity != null)
- {
- nonDCItems.add(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_9);
- }
- if(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_10_Quantity > 0 && Quote_Builder[ID == input.firstQuoteID].Non_Discountable_10_Quantity != null)
- {
- nonDCItems.add(Quote_Builder[ID == input.firstQuoteID].Non_Discountable_10);
- }
It basically checks if the Quantity field on the form is higher than 0, and if so, it saves the name of the dropdown field into the list.
Here is the code that I am using later in the script to access the list names.
- //STARTS THE FOR EACH MACRO FOR DEMO ITEMS + NON DISCOUNTABLE ITEMS
- <%
- for each item in nonDCItems
- {
- %>
- <pr width='fill' height='auto'>
- <pc padding='0px' width='50%'>
- <pr width='auto' height='auto'>
- <pc>
- <text marginLeft='20px' marginBottom='5px' marginTop='5px' color='#1F58B8' size='16px' fontFamily='roboto-regular' type='Text' bgColor='rgba(0, 0, 0, 0)' value='<%=item%> '> </text>
-
- </pc>
- </pr>
- </pc>
- <pc padding='0px' bgColor='transparent' width='50%' hAlign='right' vAlign='middle'>
- <pr width='auto' height='auto'>
- <pc>
- <text marginRight='20px' marginBottom='5px' marginTop='5px' color='#1F58B8' size='16px' fontFamily='roboto-regular' type='Text' bgColor='rgba(0, 0, 0, 0)' value=''> </text>
- </pc>
- </pr>
- </pc>
- </pr>
- <%
- }
- %>
Here is where things get weird.
Remember how I loaded the dropdown options for the form fields from a script on form load?
If any of these variables are selected in the form, I get a ZML error.
If I go back into the reports and edit the form in said area, I notice that the pre-populated options are no longer there and are replaced with the default choices. "Choice 1, Choice 2, Choice 3"
If I select from these choices and remove the choices with the pre populated variables, the code works and displays as intended:
I am confused on how to proceed.
It seems the problem exists somewhere in how I have chosen to prepopulate the fields, because the code only works when none of those fields are selected.
Please advise!