Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pickListValues not an array of picklistValues but single picklistValue #221

Closed
aranwe opened this issue Nov 26, 2024 · 3 comments · Fixed by #222
Closed

pickListValues not an array of picklistValues but single picklistValue #221

aranwe opened this issue Nov 26, 2024 · 3 comments · Fixed by #222
Assignees
Labels
bug Something isn't working

Comments

@aranwe
Copy link

aranwe commented Nov 26, 2024

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

@cesarParra
Copy link
Owner

Thanks @aranwe , I was able to reproduce. The issue is due to the way that the fast-xml-parser parses that data when there is a single node vs. many. Your solution should work, since there is already a validation in there making sure that the value key exists (if there are 0 nodes it won't be there).

Let me me put that in place and release a new version

@cesarParra cesarParra added bug Something isn't working and removed investigating labels Nov 26, 2024
@cesarParra
Copy link
Owner

Fix is in 3.7.1. Feel free to reopen if you see any issues!

@aranwe
Copy link
Author

aranwe commented Nov 26, 2024

Yup, tested, new release works fine :)

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants