Copying Umbraco datatype settings (prevalues).
I had to copy a grid with settings and our "default template" settings today. Given there's no copy datatype feature in Umbraco yet, I had the option of ticking all the boxes manually, or invent a quicker way. So I ended up just doing a quick hack in SQL to do the work for me. I'm mostly putting it here for my own reference for later, but maybe - just maybe it's useful for you too. :)
If you create a new datatype with the same property editor in the backoffice, you can compare it's settings with an existing one as such:
select
*
FROM
cmsDataTypePreValues target
inner join cmsDataTypePreValues source on
source.datatypenodeId = 1048 and target.datatypenodeid = 1630
and
source.alias = target.alias
Just swap out 1038 and 1630 with your respective source values. If you run the query you'll see that we'd like the values on the right to be copied to the left ones. That's just a matter of running and update. Wrap it in a transaction just to check that you don't update 1000 prevalues inadvertently:
begin tran
go
update target set
target.value = source.value
FROM
cmsDataTypePreValues target
inner join cmsDataTypePreValues source on
source.datatypenodeId = 1048 and target.datatypenodeid = 1630
and
source.alias = target.alias
go
rollback tran
If it says it updated as many rows as you have settings, you're in the green and can swap the rollback tran
to a commit tran
and there you go. All settings copied.
Now all we've got to do is wrap this in a WebAPI call and we've almost got the copy/paste datatypes feature in Umbraco. :)