Skip to content

pickListValues not an array of picklistValues but single picklistValue #221

Closed
@aranwe

Description

@aranwe

Hi,

When generating apexdocs markdown it fails in:

return pickListValues.filter((each) => 'fullName' in each).map((current) => current.fullName);

with error:

    return pickListValues.filter((each) => "fullName" in each).map((current) => current.fullName);
                              ^

TypeError: pickListValues.filter is not a function
    at toPickListValues (...\node-versions\v22.3.0\installation\node_modules\@cparra\apexdocs\dist\logger-DC5HNMQO.js:1946:31)
...

The point where it fails is for CustomObject (name and label replaced) where there is only 1 value inside valueSetDefinition:

<?xml version="1.0" encoding="utf-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>Test__c</fullName>
    <externalId>false</externalId>
    <inlineHelpText>Test</inlineHelpText>
    <label>Test</label>
    <required>false</required>
    <trackFeedHistory>false</trackFeedHistory>
    <trackHistory>false</trackHistory>
    <type>Picklist</type>
    <valueSet>
        <restricted>true</restricted>
        <valueSetDefinition>
            <sorted>false</sorted>
            <value>
                <fullName>TBD</fullName>
                <default>false</default>
                <label>TBD</label>
            </value>
        </valueSetDefinition>
    </valueSet>
</CustomField>

This dummy fix helps: (not the best solution though as there is probably more occurencies where xml nodes can be 0,1 or many and are returned as either array or single node)

        if (Array.isArray(pickListValues)) {
          return pickListValues.filter((each) => "fullName" in each).map((current) => current.fullName);
        }
        if ("fullName" in pickListValues) {
          return pickListValues.fullName;
        }

ApexDocs version: 3.7.0
Node version: 22.3.0
Platform: win-x64

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions