Is the Query Module broken?

The netsuite query module is broken. Run the following query  in your account code and you’ll get listed values instead of grouped ones. In the occurances variable you’ll see how many there are for each entity. There should never be more than 1


let myQuery = query.create({

type: 'transaction'

});

let transactionlinesJoin = myQuery.autoJoin({ fieldId:'transactionlines'});

let accountingimpactJoin = transactionlinesJoin.autoJoin({ fieldId:'accountingimpact'});

myQuery.columns = [

accountingimpactJoin.createColumn({fieldId: "amount", alias: "amount", aggregate:query.Aggregate.SUM, context: query.FieldContext.CURRENCY_CONSOLIDATED}),

myQuery.createColumn({fieldId: "entity", alias: "entity", groupBy:true, context: query.FieldContext.DISPLAY})];

let resultSet = myQuery.runPaged({pageSize:1000});

let occurrances = {};

for (let i = 0; i < resultSet.pageRanges.length; i++) {

let thisPage = resultSet.fetch({ index: i });

let pagedResults = thisPage.data.asMappedResults();

pagedResults.forEach( (mappedResult) => {

let {amount, entity} = mappedResult;

if (occurrances[entity] === undefined) occurrances[entity] = 0;

occurrances[entity]++

console.log(entity, amount);

});

}

Beginner Asked on May 2, 2022 in SuiteScript.
Add Comment
1 Answer(s)

I’ve just run that and don’t see any multiple occurrences.

Do you have multibooks or anything?

Intermediate Answered on May 17, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor