CustomMetadataLoader icon indicating copy to clipboard operation
CustomMetadataLoader copied to clipboard

Empty value issue

Open michacom opened this issue 7 years ago • 5 comments

My CSV file looks like

DeveloperName,Level__c,Containing_Node_Label__c,Type__c,FieldA__c,FieldB__c,FieldC__c
OpportunityStage,0,,Field,,StageName,
Contacts,0,,List,Contacts_In_Opportunity__r,,

When I try upload, I'm getting this error: Error occured processing component <CUSTOM_METADATA_TYPE_NAME>.OpportunityStage. Type: bad value for restricted picklist field: StageName (INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST). Fields Type__c.

It seems, that the tool skips empty values: ,, and ,

michacom avatar Aug 28 '18 14:08 michacom

So, the issue is the way APEX .split() works. 'a,b,c'.split(',') => (a,b,c) 'a,b,'.split(',') => (a,b) 'a,,'.split(',') => (a) and so on... It may be solved with regex...

michacom avatar Aug 28 '18 16:08 michacom

This is machine translation sentences.

@michacom hi I think splitting the header row and the data row separately and resolving it by taking the number of elements of the header row as an argument.

  1. Split the header line and count the number of elements
  2. Specify the number of elements as split and the minus value as the second argument.
  3. You can get results without missing. I did it! ! And this is an ancient technique in Java

'head_col_1,head_col_3,head_col_3'.split(',').length()=>3
'a,,'.split(',',-3) => (a, , )

YuheiSugawara avatar Aug 30 '18 03:08 YuheiSugawara

Workaround until the solution is fixed:

My csv was like

Label,Field_A__c,Field_B__c,Field_C__c

Field_C__c had some empty values, so I ended up making 2 different csv files one with Field_C__c and one without. worked for me

amanjareck avatar Jan 15 '19 19:01 amanjareck

I've proposed a simple fix here, which works for me. Interested to hear if it breaks anything else?

https://github.com/forcedotcom/CustomMetadataLoader/commit/1a6c01a51c462ec3b67f3d5ff5f7e3aa74a62e73

alex-wilson-gwf avatar Apr 27 '23 05:04 alex-wilson-gwf

Duplicate of https://github.com/forcedotcom/CustomMetadataLoader/issues/9

alex-wilson-gwf avatar Apr 27 '23 05:04 alex-wilson-gwf