I get silent error in MapReduce script (nothing is...
# ask-stanley-ai
a
I get silent error in MapReduce script (nothing is even caught in a try/catch, only shows up in MapReduce status details), when my getInputData function returns a Query object. Why?
c
AI generated answer (using internal Slack threads):
The error you're encountering in your MapReduce script when your getInputData function returns a Query object is likely due to the fact that the MapReduce script is expecting an array or a search object, not a Query object. In SuiteScript 2.0, the getInputData stage of a MapReduce script can return one of the following types of objects: 1. An array of objects. 2. A search.Search object. 3. An object with the following format:
{type: 'search', id: 'customsearch_my_search'}
. 4. An object with the following format:
{type: 'suiteql', query: 'SELECT * FROM transaction'}
. If you're using SuiteQL for your query, you should return an object with the type 'suiteql' and your query string, as shown in the fourth example above. Here's an example of how you can return a SuiteQL query from the getInputData function:
Copy code
javascript
function getInputData() {
    return {
        type: 'suiteql',
        query: 'SELECT * FROM transaction'
    };
}
If you're using a saved search, you should return an object with the type 'search' and the ID of your saved search, as shown in the third example above. Here's an example of how you can return a saved search from the getInputData function:
Copy code
javascript
function getInputData() {
    return {
        type: 'search',
        id: 'customsearch_my_search'
    };
}
If you're using an array of objects, make sure that each object in the array has a unique key that can be used by the MapReduce script to process each object individually. Here's an example of how you can return an array of objects from the getInputData function:
Copy code
javascript
function getInputData() {
    return [
        {id: 1, name: 'Object 1'},
        {id: 2, name: 'Object 2'},
        // More objects...
    ];
}
If you're using a search.Search object, you can simply return the search object from the getInputData function. Here's an example of how you can return a search.Search object from the getInputData function:
Copy code
javascript
function getInputData() {
    var searchObj = search.create({
        type: 'transaction',
        // More search configuration...
    });
    return searchObj;
}
Remember to replace the examples above with your actual data or search configuration. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840740144
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.835378
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832984269
Please provide your feedback on this answer.