I'm having issues pulling sales results. Here's what my code looks like.
I'm having an issue, here's what my actions looks like for a button I’ve created:
1 Assign Value to Action Result - create resultWhereSales for use with date calculations
2 Assign Value to Action Result - Assign Start Date to resultEndDateTest
3 Assign Value to Action Result - Assign Start Date to resultStartDateTest
4 Date Function - Format resultEndDateTest as MM/dd/yy
5 Date Function - Format resultStartDateTest as MM/dd/yy
6 Start Loop Through Table - Loop through customer table
7 Start Conditional Statement - If no parent
8 Assign Value to Action Result - Assign FullName to resultCustomerName
9 Character Function - resultWhereSales = resultWhereSales + Merge resultEndDateTest
10 Character Function - resultWhereSales = resultWhereSales + Merge resultStartDateTest
11 Character Function - resultWhereSales= resultWhereSales + Merge Customer
12 Retrieve Value From Table - resultSalesAmount = sum of where resultWhereSales
13 Insert Records Into Table
14 End Conditional Statement
15 End Loop Through Table
Notes:
- The resultWhereSales for use when looping through the Invoice table looks like this:
(Customer = 'CustomerName:Main account') AND (TXNDATE >= 'StartDate' AND TXNDATE <= 'EndDate')
In the looping action, I replace “CustomerName” with the parent name for each customer. I also replace the “StartDate” and “EndDate” text with action results based off date-picker drop-downs on the screen.
- Regarding tables, I am looping through the Customer table (Action 6), pulling sales data from the Invoice table (Action 12), and inserting records into a custom “SalesandMarketing” table (Action 13)
Anyway, if, as a test I hard-code an actual customer name into the “CustomerName” part of the resultWhereSales script and then enter the value pulled from the Invoice table onto a field on-screen, I get a correct number. Keep in mind for this test I'm not creating records in the "SalesandMarketing" table (I removed the Action 13), I'm just entering the sales for a single customer into a field on the screen instead.
However, if I leave the script as-is, loop through the Customer table and try to pull sales results from the Invoice table for all applicable customers, then the SalesandMarketing table shows rows with all customers, but the sales are all $0.
Please advise.