TransWikia.com

transform records from jsforce bulk api query

Salesforce Asked on November 5, 2021

I am trying to modify the results of a query that uses the bulk api by using the recordStream.on(‘record’,…) function. I’ve stepped through the code but it making modifications here (or in other streams under the recordStream) has no effect on the final output. Does anyone know how to do this?

Here is example code:

const recordStream = conn.bulk.query(soql);
const readStream = recordStream.stream();

return new Promise((resolve, reject) => {
    // examine each record and make some mod to it
    // in an attempt to get the change to show up in the next pipe
    recordStream.on('record', (doc) => {
       doc.someProp = someTransform(doc.someProp);
    });

    readStream
        .pipe(fs.createWriteStream(fileName));
});

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP