it returns all the customfield but i only wants to...
# ask-stanley-ai
b
it returns all the customfield but i only wants to get the list of matrix option that i have created like size color and parts all of these have enabled matrix option how can i get only these custom fields using suiteql
c
AI generated answer (using internal Slack threads):
To get only the custom fields that have the matrix option enabled, you can use SuiteQL to query the CustomField table. However, there is no direct way to filter out only those fields that have the matrix option enabled. You can try to load actual item records and look for fields with the matrixoption prefix. This is a bit of a workaround, but it might be the only way to achieve this in SuiteScript. Here is a sample code snippet:
Copy code
javascript
var itemLoad = record.load({
    type: record.Type.INVENTORY_ITEM, 
    id: 'your_item_id'
});

var fieldCount = itemLoad.getFieldCount();

for (var i = 0; i < fieldCount; i++) {
    var fieldId = itemLoad.getField({
        fieldId: i
    }).id;

    if (fieldId.startsWith('matrixoption')) {
        // This is a matrix field
    }
}
Please note that this code will only work for inventory items. If you have other types of items (like non-inventory, service, etc.), you will need to adjust the
record.Type
accordingly. ****** 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.837281227
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.814290166
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.807563245
Please provide your feedback on this answer.