Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.

 

Custom EPiServer CMS Property

Vote:
 

I'm looking to create a custom CMS property and that saves values to the Commerce DB instead of the CMS DB. The values would have to be parsed to save the data accordingly. For example:

USA=Estados Unidos,
BGR=Bielorrusia

Is this possible to create a custom property to parse this and save it to a newly created business foundation object?

#70652
Apr 24, 2013 16:25
Vote:
 

Hi!

Why do you want to save the data for your CMS property in a Commerce object instead of the actual CMS object? What is it that you are trying to achieve?

#70656
Apr 25, 2013 7:40
Vote:
 

Yes I want to save it as a Commerce object instead of a CMS object. After doing more research on the issue, I see that there is a CountryDto and a CountryManager. Is there a way to extend these classes and to accomodate country name translations?

#70678
Apr 25, 2013 18:55
Vote:
 

Hi!

Though you can do pretty much anything in a custom property I have never heard about someone doing something like this. The reason for this is that a custom property is just a piece of code that handles a bit of data. It does not know much about the parent object or it's life cycle. The normal aproach when dealing with other systems is to make a property that holds a reference to an object stored elsewhere, but not to actually create and manage this object.

If you need to do this I would probably add an event handler to the parent object (for instance a page) and make sure that I update the external system (for instance Commerce) whenever the object is being published.

#70682
Apr 26, 2013 7:28
Vote:
 

I agree, hooking up on for example SavingPage or SavedPage event seems a bit more kosher

#70685
Apr 26, 2013 9:03
Vote:
 

Cool. Thanks for the explanation. It makes a lot more sense.

#70695
Apr 26, 2013 13:30
Vote:
 

Quick update:

I've tried what you suggested and it works so far. The question I have now is where is the SavingPage or SavedPage method? I only see SaveData method and I don't think I'm suppose to be using this to save/merge changes to the DB.

#70764
Apr 29, 2013 17:39
Vote:
 

Check out the PublishingContent event on DataFactory.Instance. You can also fetch out the registered instance for the interface "IContentEvents" if you want to work with the IOC container for testability.

#70765
Apr 29, 2013 17:50
Vote:
 

So I would have to modify the save method in the PageType that uses the custom property? There isn't a way to do this in the custom property itself?

I'm sorry for importuning you guys with questions. I'm still new to EPiServer and still learning the EPiServer system.

#70766
Apr 29, 2013 18:44
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.