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

sfdx cmdt:record:insert creates incorrect undefined field in record #2074

Closed
sarahbrock opened this issue Apr 17, 2023 · 15 comments
Closed

sfdx cmdt:record:insert creates incorrect undefined field in record #2074

sarahbrock opened this issue Apr 17, 2023 · 15 comments
Labels
bug Issue or pull request that identifies or fixes a bug

Comments

@sarahbrock
Copy link

Summary

When using sfdx cmdt:record:insert (or sfdx force:cmdt:record:insert or sfdx cmdt generate records) and processing a CSV. The generated customMetadata records always contain an undefined field whether the namecolumn parameter is used or not.

Steps To Reproduce:

A CustomMetadata Object, Dashboard_ID_mdt been created with the following text fields:
Position__c
Random_Value_Name__c

And when attempting to create records using the following CLI syntax in VSCode
sfdx force:cmdt:record:insert --filepath List.csv --typename Dashboard_ID --namecolumn Random_Value_Name__c

the metadata records are being created, but an extra undefined field is also created :(

Expected result

The metadata should be as follows:

aaa false Position__c 1 Random_Value_Name__c aaa

Actual result

The records are being inserted, but have an extra undefined field defined:

aaa false undefined undefined Position__c 1 Random_Value_Name__c aaa

System Information

  • Which shell/terminal are you using? (e.g. bash, zsh, powershell 5, powershell 7, cmd.exe, etc.) - zsh

{
"cliVersion": "sfdx-cli/7.194.1",
"architecture": "darwin-x64",
"nodeVersion": "node-v18.15.0",
"osVersion": "Darwin 22.3.0",
"shell": "zsh",
"rootPath": "/Users/sarah/.local/share/sfdx/client/7.194.1-faa045e",
"pluginVersions": [
"@oclif/plugin-autocomplete 2.1.6 (core)",
"@oclif/plugin-commands 2.2.11 (core)",
"@oclif/plugin-help 5.2.8 (core)",
"@oclif/plugin-not-found 2.3.22 (core)",
"@oclif/plugin-plugins 2.4.3 (core)",
"@oclif/plugin-search 0.0.14 (core)",
"@oclif/plugin-update 3.1.8 (core)",
"@oclif/plugin-version 1.3.1 (core)",
"@oclif/plugin-warn-if-update-available 2.0.32 (core)",
"@oclif/plugin-which 2.2.17 (core)",
"apex 2.2.7 (core)",
"auth 2.7.10 (core)",
"community 2.2.8 (core)",
"custom-metadata 2.1.9 (core)",
"data 2.3.8 (core)",
"info 2.6.2 (core)",
"limits 2.3.9 (core)",
"org 2.6.2 (core)",
"packaging 1.16.2 (core)",
"schema 2.3.4 (core)",
"settings 1.4.2 (core)",
"signups 1.4.8 (core)",
"source 2.8.0 (core)",
"telemetry 2.1.3 (core)",
"templates 55.4.4 (core)",
"trust 2.4.5 (core)",
"user 2.3.5 (core)",
"@salesforce/sfdx-plugin-lwc-test 1.0.1 (core)",
"sfdx-cli 7.194.1 (core)"
]
}

Additional information

csv file attached
thank you
Uploading List.csv…

@sarahbrock sarahbrock added the investigating We're actively investigating this issue label Apr 17, 2023
@github-actions
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@WillieRuemmele
Copy link
Member

Hey @sarahbrock - thanks for this information, I'm still having a hard time reproducing this... can you write out the steps to recreate this?

I tried

  1. create custom metadata Dashboard_ID in the org
  2. add 2 text fields, Random_Value_Name, and Position
  3. downloaded your .csv
  4. and tried to run sfdx force cmdt record insert --csv ~/Downloads/List.csv --type-name Dashboard_ID__mdt --name-column Random_Value_Name__c
  5. I got the error Error (1): The column Random_Value_Name__c is not found on the custom metadata type Dashboard_ID.

@WillieRuemmele WillieRuemmele added more information required Issue requires more information or a response from the customer and removed investigating We're actively investigating this issue labels Apr 17, 2023
@sarahbrock
Copy link
Author

sarahbrock commented Apr 17, 2023 via email

@WillieRuemmele
Copy link
Member

It shouldn't matter where the command is executed from.
After creating my own custom metadata type, test and 2 text fields (cf1, cf2) I was able to run the command
sfdx force cmdt record insert --csv fields.csv --type-name test --name-column cf1__c
with the .csv contents

cf1__c,cf2__c
ab,cd
ef,gh

it then created two files in the force-app/main/default/customMetadata
test.ab.md-meta.xml, and test.ef...
and their contents

<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <label>ab</label>
    <protected>false</protected>
    <values>
        <field>cf1__c</field>
        <value xsi:type="xsd:string">ab</value>
    </values>
    <values>
        <field>cf2__c</field>
        <value xsi:type="xsd:string">cd</value>
    </values>
</CustomMetadata>

When I downloaded your attached list.csv file, there were some weird characters in there, that could cause the issue

@sarahbrock
Copy link
Author

sarahbrock commented Apr 18, 2023 via email

@WillieRuemmele
Copy link
Member

Hey @sarahbrock - I now understand, thank you for the clarification...

just as a note:

you need to pull the new field into the org before running the command for the second time
reproduced: sfdx-cli/7.198.4 darwin-arm64 node-v18.7.0
and see

    <values>
        <field>undefined</field>
        <value xsi:type="xsd:string">undefined</value>
    </values>
</CustomMetadata>

@WillieRuemmele WillieRuemmele added bug Issue or pull request that identifies or fixes a bug and removed more information required Issue requires more information or a response from the customer labels Apr 18, 2023
@git2gus
Copy link

git2gus bot commented Apr 18, 2023

This issue has been linked to a new work item: W-13055835

@bobmatt3
Copy link

What is the ETA for this bug to be fixed?
I have had to downgrade to a previous version of the CLI in order for this functionality to work.

@RCdmv
Copy link

RCdmv commented Aug 22, 2023

I'm getting the same error with an 'undefined' field being added using cmdt:record:insert.

@louisskelton
Copy link

I'm also getting this error - can we have an update? Many Thanks.

@RCdmv
Copy link

RCdmv commented Sep 7, 2023

I got around it by doing a find and replace to remove the 'undefined' section from the metadata definition.

@FeiyangGao
Copy link

wuwu, I have to created more than 30 records, manully. every quarter.

@SourabhMulay
Copy link

Any Updates on this one???. Because creating hundreds of records manually without External package is like ............

@jshackell-sfdc
Copy link
Collaborator

This issue is fixed in 2.20.7 (Dec 6, 2023).

@ljmarzo
Copy link

ljmarzo commented Dec 14, 2023

Still giving me undefined
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug
Projects
None yet
Development

No branches or pull requests

9 participants