Sunday, January 28, 2007

Letting the CD Generate the Anchor with an XMA

The MIIS developer reference includes a provisioning sample for systems that generate the anchor attribute. Pretty simple idea, at provision time you set the anchor to some random value that will get thrown away. After export the target system will generate the anchor for you, then on import you have a shiny new object with a new anchor.

In an XMA you can do this too, but it takes just a little more work. It wasn't intuitive to me until I saw it work, then it was pretty cool.

In your XMA code's ExportEntry routine you export the addition using whatever call you need to. If that call returns the ID of the thing you just created, then it has just created the anchor for you. You can then take that anchor and put it on the csEntry.

The pseudo code looks like this:
ExportEntry()
{
if modificationType == Add
{
export the addition
get the anchor of the exported addition
put the anchor on the csentry using csentry["yourAnchorAttribute"].value = NewAnchor
}
}

Cool!

No comments: