Marvin
10/18/2022, 6:41 PMquery.load
.
Is it possible to add an additional filter to the existing ones in a script?
Basically the dataset won't include the record id that I want to search, but a lot of other filters necessary that I want to be able to tweak more easily than in code. But I want the script to just add the record id when it loads and runs the query.dcrsmith
10/18/2022, 8:16 PMQuery.createCondition(options)
to add additional conditions/criteria/filters (whatever you want to call them)Marvin
10/18/2022, 9:35 PMconst test_query = query.create({
type: query.Type.TRANSACTION
});
test_query.condition = test_query.and(
test_query.createCondition({
fieldId: 'id',
operator: query.Operator.ANY_OF,
values: [record_id]
})
);
Are you saying that if I do this it will work and not zero out the existing conditions and just add the new one?
const test_query = query.create({
id: 'dataset_id'
});
test_query.condition = test_query.and(
test_query.createCondition({
fieldId: 'id',
operator: query.Operator.ANY_OF,
values: [record_id]
})
);
dcrsmith
10/18/2022, 10:47 PMrequire(['N','N/ui/dialog'], function(N,dialog) {
for(var n in N){window[n] = N[n];};
try{
var myLoadedQuery = query.load({
id: 'custdataset13'
});
console.log(myLoadedQuery);
console.log(myLoadedQuery.run().asMappedResults());
myLoadedQuery.condition = myLoadedQuery.and(
myLoadedQuery.condition, myLoadedQuery.createCondition({
fieldId: 'assigned',
operator: query.Operator.EQUAL,
values: 3959
})
);
console.log(myLoadedQuery.run().asMappedResults());
} catch(e){console.error(e.message);}})
Marvin
10/19/2022, 6:04 PM