ShepherdDev / rock-misc

A collection of miscellaneous stuff for use with Rock.
11 stars 4 forks source link

Attempt to Import WF Fails #3

Closed DerekMangrum closed 7 years ago

DerekMangrum commented 7 years ago

Using the ShareWorkflow block, I attempted to import this workflow into multiple servers and got this error each time. image

The Exception List on the Rock Server has not record of the error/exception.

Attached is the ShareWorkflow Export file (in the .zip).

RockPaperScissors.zip

nairdo commented 7 years ago

The problem occurs when attempting to add an AttributeValue whose guid is e7bcddbd-f5a2-4f63-a56b-7f5cb5f154a9 and value is "`<a href="{{ ButtonLink }}" onclick="{{ ButtonClick }}" data-loading-text=" {{ ButtonText }}" class="btn btn-default"

{{ ButtonText }} `"

...however, that AttributeValue is on my system with a different guid.

Its two related entities (Attribute and DefinedValue**) also already exist but the CreateNewEntity helper didn't find/map them -- so while trying to add that AttributeValue, it tries to create/insert them again which throws this inner exception:

"Cannot insert duplicate key row in object 'dbo.AttributeValue' with unique index 'IX_AttributeIdEntityId'. The duplicate key value is (985, 259).\r\nThe statement has been terminated."

** Notes:

select * from Attribute where guid = '6ff59f53-28ea-4bfe-afe1-a459cc588495' -- id is 985
select * from DefinedValue where guid = '8cf6e927-4fa5-4241-991c-391038b79631' -- id is 259
cabal95 commented 7 years ago

Hmm. Based on the log it seems that it did indeed find the Attribute (since it didn't create it). So, I am guessing that this is an AttributeValue on a DefinedValue, and the DefinedValue existed on the exporting system as well as the importing system.

Is that indeed the case? There is probably an un-intended assumption in the code that if we are creating an AttributeValue that we also created the entity it references.

I might have to do some extra conditional checking with AttributeValue's to do a more thorough check for existing values. It is odd that I haven't run into that before. Also the exception not being logged is my fault. I didn't realize there was a standalone method for logging an exception from inside a catch block until very recently.

And I must say, the name of the workflow has peaked my interest. :)

nairdo commented 7 years ago

Yes, that appears to be the case. The workflow refers (AttributeValue) to a button which is an attribute on the "Button HTML" Defined Type.

Derek implemented rock-paper-scissors game as a workflow form. It's a pretty cool example of what you can do with workflows and I don't want to lose it :)

cabal95 commented 7 years ago

I'll play around with this and test various import options and see if I can resolve that duplicate AttributeValue. I already had to do a special check on Attribute to see if it existed by Guid or by it's key name, I probably just need to do the same on AttributeValue as well.