HOME DOCUMENTATION DOWNLOADS BLOG

ERROR - Expected 1 value(s) for key index but received 2 vlue(s)

When processing rules in BankAccountStatement form I get following error:

Vykonání pravidla ve formuláři ‘Banka’
Selhalo vykonání pravidla při změně záznamu v entitě ‘‘Likvidace úhrady dokladu’’.
Expecting 1 value(s) for the key being indexed, but received 2 value(s).

Selhalo vykonání pravidla při změně záznamu v entitě ‘‘Likvidace úhrady dokladu’’.
Expecting 1 value(s) for the key being indexed, but received 2 value(s).

Expecting 1 value(s) for the key being indexed, but received 2 value(s).

========================================
Stack trace

at System.Data.Index.FindRecords(Object[] key)
at System.Data.DataTable.FindRow(DataKey key, Object[] values)
at System.Data.DataRowCollection.Find(Object[] keys)
at CZ.Advantages.Asap.Rule.RuleEngine.ProcessRulesInternalFinish(ArrayList rules, XmlDataDocument data, DataRow rowChanged, OutputPad outputPad, DataStructureRuleSet ruleSet)
at CZ.Advantages.Asap.Rule.RuleEngine.ProcessRulesInternal(DataRow rowChanged, XmlDataDocument data, DataColumn columnChanged, DataStructureRuleSet ruleSet, ICollection columnsChanged, Boolean isFromRuleQueue)
at CZ.Advantages.Asap.Rule.RuleEngine.ProcessRuleQueue()
at CZ.Advantages.Asap.Rule.RuleEngine.ProcessRules(DataRow rowChanged, XmlDataDocument data, DataStructureRuleSet ruleSet, DataRow[] parentRows)
at CZ.Advantages.Asap.Rule.DatasetRuleHandler.OnRowChanged(DataRowChangeEventArgs e, XmlDataDocument data, DataStructureRuleSet ruleSet, RuleEngine ruleEngine) at CZ.Advantages.Asap.Rule.DatasetRuleHandler.OnRowChanged(DataRowChangeEventArgs e, XmlDataDocument data, DataStructureRuleSet ruleSet, RuleEngine ruleEngine)
at CZ.Advantages.Asap.Gui.Win.FormGenerator.table_RowChanged(Object sender, DataRowChangeEventArgs e)

Any suggestions how to solve this? According to me the data is OK, no duplicities in anywhere.

Thanky for any advice.

By looking at the error message it seems that there are 2 primary keys somewhere in the data model.

What you should try to investigate:

  • didn’t you enhance your entity to contain a second primary key (additionally to Id)?
  • didn’t you enhance some of the data relationships to contain 2 keys? (check the data structure under your screen and the relationships defined in the connected entities)

Otherwise it is important to know exact steps on how to reproduce the error.

Resolved.

The problem was caused when AllFileds=False property was set. Then ORIGAM generated two primary keys one was obviously Id and the other one was _mockPk.

Solution was either deleting _mockPk or setting AllFields property to True. I therefore suspect ORIGAM that it behaves the way that it can handle two primary keys when property AllFields is True and cannot handle two primary keys when it is False.

Why is that?

Please notice that ExcludeFromAllFields=True for the _mockPk field. Therefore it is not included when AllFields=True and so it works…