London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

IsPrimary cannot be Null

Vote:
0

I am doing a migration job. I have an xml with data and i am importing it to Catalog.
On some items i get following error:
Any idea to why?

2019-07-04T04:54:58,Warning,ktms03mstrqx112prep,ab7fea,636978128988831035,0,8452,203,KTM.Integrations.PIM.EPi.ScheduledJobs.PimXmlAzureImportJobMaster : Parsing of '$M-25105981000' failed skipping product import,80000149-0002-fe00-b63f-84710c7967bb   
2019-07-04T04:54:58,Error,ktms03mstrqx112prep,ab7fea,636978128988831035,0,8452,203,"KTM.Integrations.PIM.EPi.ScheduledJobs.PimXmlAzureImportJobMaster : Column 'IsPrimary' does not allow nulls.   
System.Data.NoNullAllowedException: Column 'IsPrimary' does not allow nulls.   
   at System.Data.DataColumn.CheckNullable(DataRow row)   
   at System.Data.DataTable.RaiseRowChanging(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction, Boolean fireEvent)   
   at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean suppressEnsurePropertyChanged, Int32 position, Boolean fireEvent, Exception& deferredException)   
   at System.Data.DataTable.InsertRow(DataRow row, Int64 proposedID, Int32 pos, Boolean fireEvent)   
   at KTM.Integrations.PIM.EPi.Data.Parsers.CommerceParserBase.CreateUpdateRelation(Int32 catalogId, Int32 nodeId, Int32 entryId, Int32 sortOrder)   
   at KTM.Integrations.PIM.EPi.Data.Parsers.StructureParser.ParseProduct(String code, String parent, CatalogType type, TextElementCollectionDescriptor texts)   
   at KTM.Integrations.PIM.EPi.Data.Parsers.StructureParser.Parse()   
   at KTM.Integrations.PIM.EPi.Data.Parsers.DataParser.TryRun(Action action, Action`1 errorAction)",80000149-0002-fe00-b63f-84710c7967bb


****** CODE *****

protected CatalogRelationDto.NodeEntryRelationRow CreateUpdateRelation(int catalogId, int nodeId, int entryId, int sortOrder)
{
var relationDto = GetRelationDto(catalogId, nodeId, entryId);

CatalogRelationDto.NodeEntryRelationRow relation = null;

foreach (var entryRelation in relationDto.NodeEntryRelation.ToList<CatalogRelationDto.NodeEntryRelationRow>())
{
if (entryRelation.CatalogEntryId.Equals(entryId) &&
entryRelation.CatalogNodeId.Equals(nodeId))
{
relation = entryRelation;
continue;
}

relationDto.NodeEntryRelation.RemoveNodeEntryRelationRow(entryRelation);
}

if (relation == null)
{
relation = relationDto.NodeEntryRelation.NewNodeEntryRelationRow();
relation.CatalogId = catalogId;
relation.CatalogNodeId = nodeId;
relation.CatalogEntryId = entryId;
}

relation.SortOrder = sortOrder;

if (relation.RowState.Equals(DataRowState.Detached))
{
relationDto.NodeEntryRelation.AddNodeEntryRelationRow(relation);
}
else
{
relation.AcceptChanges();
}

if (relationDto.HasChanges())
{
_catalogSystem.SaveCatalogRelationDto(relationDto);
}

return relation;
}



#205322
Jul 05, 2019 10:13
Vote:
0

Can you not just provide a value for this? Where you create a new relation:

if (relation == null)
{
relation = relationDto.NodeEntryRelation.NewNodeEntryRelationRow();
relation.CatalogId = catalogId;
relation.CatalogNodeId = nodeId;
relation.CatalogEntryId = entryId; 
}

IsPrimary was released in Commerce 11.2 - https://world.episerver.com/documentation/Release-Notes/?versionFilter=11.2.0&packageFilter=EPiServer.Commerce&typeFilter=All&packageGroup=Commerce

Thanks,

Paul

#205323
Edited, Jul 05, 2019 10:34
Vote:
0

Hi Paul, 

have not been working with ECF. 
Took me some time to figure it out.

https://marisks.net/2017/09/19/new-relation-apis-in-commerce-11/

I think you are correct. I will post an update as soon as i run the job again.
Unforunatly, do not have any small xml from client only a full export. Will take some time to import.
Thank you for taking the time to answer.
 

#205324
Jul 05, 2019 10:48
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.