tridion - XML validation error when updating Keyword metadata -
following on earlier question creating address books (many peter!), have small throw-away console application doing , working great - in addition i'm trying update metadata of keyword item id of created address book.
slightly shortened snippet ...
staticaddressbook ab = new staticaddressbook(); ab.title = title; ab.key = key; ab.save(); // id correct keyword tcm id keyword k = tdse.getobject(id, enumopenmode.openmodeedit); if (k != null) { k.metadatafields["addressbookid"].value[0] = ab.id.itemid; k.save(true); }
i keep getting following error on save():
xml validation error. reason: element 'metadata' in namespace 'uuid:2065d525-a365-4b45-b68e-bf45f0fba188' has invalid child element 'addressbookid' in namespace 'uuid:2065d525-a365-4b45-b68e-bf45f0fba188'. list of possible elements expected: 'contact_us_email' in namespace 'uuid:2065d525-a365-4b45-b68e-bf45f0fba188'
but know keyword has correct metadata assigned, (thats why don't bother checking!). shortened tridion xml current keyword in question:
<tcm:keyword> <tcm:data> <tcm:metadataschemaxlink:type="simple"xlink:title="ip.location.metadata" xlink:href="tcm:49-2142-8" /> <tcm:metadata> <metadata xmlns="uuid:2065d525-a365-4b45-b68e-bf45f0fba188"> <email>...</email> <addressbookid>3</addressbookid> <contact_us_email>...</contact_us_email> <request_a_sample_email>...</request_a_sample_email> <webinar_feedback_email>....</webinar_feedback_email> </metadata> </tcm:metadata> <tcm:isroot>true</tcm:isroot> </tcm:data> </tcm:keyword>
have missed can keyword metadata not updated in way?
i guess @ core service update keywords, seemed to make sense within application.
update
order key here, strangely! following code works:
itemfields fields = k.metadatafields; system.diagnostics.debug.writeline(fields.count); string email = fields[1].value[1]; string contact = fields[3].value[1]; string request = fields[4].value[1]; string webinar = fields[5].value[1]; fields[1].value[1] = email; fields[2].value[1] = ab.id.itemid; fields[3].value[1] = contact; fields[4].value[1] = request; fields[5].value[1] = webinar; k.save(true);
got caught out non-0-based index when getting/setting values , had reassign existing fields back, in order.
cheers
it seems order of fields has changed in schema since component created. @ least schema expects contact_us_email
in position current have addressbookid
.
there may other changes, i'd verify order of fields in schema , make sure component(s) match, before run tool.
Comments
Post a Comment