-
Notifications
You must be signed in to change notification settings - Fork 78
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
Comments
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. |
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
|
Are you running the CLI in VSCode?
I wonder if you will need to make sure that the newly created metadata object has been retrieved from the source org as the metadata records are created locally.
I’ve just retried in my VSCode with the following:
sfdx force:cmdt:record:insert --filepath List.csv --typename Dashboard_ID --namecolumn Random_Value_Name__c
which results in the same output with a slightly different syntax, is that worth a try?
From: Willie Ruemmele ***@***.***>
Date: Monday, 17 April 2023 at 16:51
To: forcedotcom/cli ***@***.***>
Cc: Sarah Brock ***@***.***>, Mention ***@***.***>
Subject: Re: [forcedotcom/cli] sfdx cmdt:record:insert creates incorrect undefined field in record (Issue #2074)
Hey @sarahbrock<https://github.com/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.
—
Reply to this email directly, view it on GitHub<#2074 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAGXEDHTQEPKHNZJAZ3SPMTXBVRG5ANCNFSM6AAAAAAXBJZZIE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
All information in this message and attachments is confidential and may be legally privileged. Only intended recipients are authorized to use it. E-mail transmissions are not guaranteed to be secure or error free and sender does not accept liability for such errors or omissions. The company will not accept any liability in respect of such communication that violates our e-Mail Policy.
|
It shouldn't matter where the command is executed from.
it then created two files in the
When I downloaded your attached |
Good morning, thank you for looking into this for me. I’ve been taking a further look this morning & I think I’ve isolated the issue further.
If a field is defined in the Custom Metadata but not included as a column in the csv, then the extra ‘undefined’ field value is created in the xml.
Steps to Test:
1. Create Custom Metadata Object, Dashboard_ID , with 2 fields: Random_Value_Name__c, Position__c
1. Create an import csv, fields.csv, file with the following contents:
Random_Value_Name__c, Position__c
aaa,1
aab,2
3. Insert the records by running the following command:
sfdx force:cmdt:record:insert --filepath fields.csv --typename Dashboard_ID --namecolumn Random_Value_Name__c
This will successfully create 2 CustomMetadata files with example contents as shown below:
<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>aaa</label>
<protected>false</protected>
<values>
<field>Position__c</field>
<value xsi:type="xsd:int">1</value>
</values>
<values>
<field>Random_Value_Name__c</field>
<value xsi:type="xsd:string">aaa</value>
</values>
</CustomMetadata>
4. Add a 3rd field to the Metadata Object, txt2__c, so it now contains 3 fields:
[A picture containing text, screenshot, font, algebra Description automatically generated]
5. And re-run the same command without amendment to the csv file:
sfdx force:cmdt:record:insert --filepath fields.csv --typename Dashboard_ID --namecolumn Random_Value_Name__c
Results in the Custom Metadata being updated to include the undefined value:
<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>aaa</label>
<protected>false</protected>
<values>
<field>Position__c</field>
<value xsi:type="xsd:int">1</value>
</values>
<values>
<field>Random_Value_Name__c</field>
<value xsi:type="xsd:string">aaa</value>
</values>
<values>
<field>undefined</field>
<value xsi:type="xsd:string">undefined</value>
</values>
</CustomMetadata>
Is this expected behaviour as I wouldn’t expect to need to include all fields when inserting data?
Thank you for your help with this,
Sarah
From: Willie Ruemmele ***@***.***>
Date: Monday, 17 April 2023 at 17:32
To: forcedotcom/cli ***@***.***>
Cc: Sarah Brock ***@***.***>, Mention ***@***.***>
Subject: Re: [forcedotcom/cli] sfdx cmdt:record:insert creates incorrect undefined field in record (Issue #2074)
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
—
Reply to this email directly, view it on GitHub<#2074 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAGXEDFONF7Z4XTGI6HJQSTXBVWARANCNFSM6AAAAAAXBJZZIE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
All information in this message and attachments is confidential and may be legally privileged. Only intended recipients are authorized to use it. E-mail transmissions are not guaranteed to be secure or error free and sender does not accept liability for such errors or omissions. The company will not accept any liability in respect of such communication that violates our e-Mail Policy.
|
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
|
This issue has been linked to a new work item: W-13055835 |
What is the ETA for this bug to be fixed? |
I'm getting the same error with an 'undefined' field being added using cmdt:record:insert. |
I'm also getting this error - can we have an update? Many Thanks. |
I got around it by doing a find and replace to remove the 'undefined' section from the metadata definition. |
wuwu, I have to created more than 30 records, manully. every quarter. |
Any Updates on this one???. Because creating hundreds of records manually without External package is like ............ |
This issue is fixed in 2.20.7 (Dec 6, 2023). |
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 aaaActual result
The records are being inserted, but have an extra undefined field defined:
aaa false undefined undefined Position__c 1 Random_Value_Name__c aaaSystem Information
{
"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…
The text was updated successfully, but these errors were encountered: