I have 2 budget records. I am getting the internal...
# suitescript
n
I have 2 budget records. I am getting the internal IDs using saved search. I am using SuiteQL to get the monthly amount details. It is working fine when the budgets have different field values for department, class, business unit (custom segment). But when every value is same except the business unit, it returns empty result for the other budget record (with valid internal ID). Why?
b
share the code
n
Copy code
var queryResults = query.runSuiteQL({
   query: 'Select budgets.id, budgets.account, budgets.total, budgetsMachine.period, budgetsMachine.amount from budgets INNER JOIN budgetsMachine ' +
         'ON budgetsMachine.budget = budgets.id WHERE budgets.id = ' + budgetId + ';'
});
It works for budget ID 97, but not for 109. They have same values except the business unit - which is a custom segment. Weird, isn't it?
b
potentially a permission issue
n
running as admin in a suitelet
works for other budget records if the classifications are different.
s
Tried a left join rather than inner join - might be that the budget is missing an entry for the budgetmachine table. Won't solve it, but at least it will give you something to go on
n
budgetmachine table is not created without the budget. It is actually the lines on the budget. Amount by period sublist.