A Required field is NOT Required in some cases in AEP
We mark a field as "Required" while defining the XDM schemas. Obviously if you mark a field as required, you need to pass the value of the corresponding field while loading data into the dataset created from the schema. But there are some cases where you can load data even without supplying values for those fields. Let's get into the details.
Here the fields marked with pink are the fields marked as required. Here one field of type object called "node_filed_rf" (RF is Required Field and ignore the spellig ) is marked as required whereas the other similar object "node_filed_nrf" is not required. Both of them has a Required Field.
We created a DataSet from the schema with the same name as the schema.
Here is the sample data that is loaded into the Dataset with error threshold as 80% as we expect many of the rows will not be accepted.JSON Data | Success | Comment |
---|---|---|
{"_id":"all_fields_exist","_abccominc":{"node_filed_nrf":{"nrf_under_nrf":"Sample value","rf_under_nrf":"Sample value"},"node_filed_rf":{"nrf_under_rf":"Sample value","rf_under_rf":"Sample value"},"top_level_nrf":"Sample value","top_level_rf":"Sample value"}} | Y | Success as All fields are present |
{"_id":"nrn_rf_ne","_abccominc":{"node_filed_nrf":{"nrf_under_nrf":"Sample value"},"node_filed_rf":{"nrf_under_rf":"Sample value","rf_under_rf":"Sample value"},"top_level_nrf":"Sample value","top_level_rf":"Sample value"}} | N | RF under NRN is missing |
{"_id":"nrn_rf_ex","_abccominc":{"node_filed_nrf":{"rf_under_nrf":"Sample value"},"node_filed_rf":{"nrf_under_rf":"Sample value","rf_under_rf":"Sample value"},"top_level_nrf":"Sample value","top_level_rf":"Sample value"}} | Y | RF Exists in NRN |
{"_id":"nrn_exist_empty","_abccominc":{"node_filed_nrf":{},"node_filed_rf":{"nrf_under_rf":"Sample value","rf_under_rf":"Sample value"},"top_level_nrf":"Sample value","top_level_rf":"Sample value"}} | N | NRN node exists but empty |
{"_id":"nrn_ne","_abccominc":{"node_filed_rf":{"nrf_under_rf":"Sample value","rf_under_rf":"Sample value"},"top_level_nrf":"Sample value","top_level_rf":"Sample value"}} | Y | The NRN doesn't exists at all |
{"_id":"rfn_rf_ex","_abccominc":{"node_filed_rf":{"rf_under_rf":"Sample value"},"top_level_nrf":"Sample value","top_level_rf":"Sample value"}} | Y | RF in RFN exists |
{"_id":"rfn_rf_ne","_abccominc":{"node_filed_rf":{"nrf_under_rf":"Sample value"},"top_level_nrf":"Sample value","top_level_rf":"Sample value"}} | N | RF in RFN doesn't exist |
{"_id":"rfn_exist_empty","_abccominc":{"node_filed_rf":{},"top_level_nrf":"Sample value","top_level_rf":"Sample value"}} | N | RFN node eixsts with empty value |
{"_id":"rfn_ne","_abccominc":{"top_level_nrf":"Sample value","top_level_rf":"Sample value"}} | N | _abccominc exists but RFN under it doesn't exist |
{"_id":"top_level_rf_ne","_abccominc":{"node_filed_nrf":{"nrf_under_nrf":"Sample value","rf_under_nrf":"Sample value"},"node_filed_rf":{"nrf_under_rf":"Sample value","rf_under_rf":"Sample value"},"top_level_nrf":"Sample value"}} | N | Top level RD missing |
{"_id":"no_custom_field_exist"} | Y | _abccominc node itself doesn't exist so missing RFN doesn't matter |
RD = Required Fields, NRN = Not required node, RFN = Required Field Node
Error: Error: Missing Required Field {field}.
Summary:
- If you want a field to be "Real" required, then make sure the whole chain leading to field is marked as required
- If a field is required, it must be there if it's parent node (object) exists and even if the parent is just an empty object "{}"
- Finally, there can't be any custom field that is "real" required. As the custom field will be part of the org specific node (Object) as in this case "_abccominc" and this node is read only and you can't mark it "Required" (refer to below picture)
Comments
Post a Comment