Import data into module built with module builder

Posted by Community Admin on 04-Aug-2018 17:45

Import data into module built with module builder

All Replies

Posted by Community Admin on 10-Jan-2012 00:00

First, I'm loving the module builder (just like everyone else.)

I am playing around with it, and I have a question. I've created my module and it's generated tables in the database. Does anyone have a suggestion for importing data into the module to jump start its content? (I was hoping I could just run a little query in SQL, but I have a feeling you're going to tell me to use the API.) I've written a query, but I don't know what to do about the id. 

J

Posted by Community Admin on 10-Jan-2012 00:00

the official reccomended way for adding data to any component of Sitefinity is definitely the API. manipulation of the database table directly is not recommended nor I believe officially supported. The API takes care of everything needed to safely add items including generating the guids and populating associated tables (taxonomy, choice fields, etc)

The code reference available in the module builder is helpful in giving you a starting point for this. If you need additional insight or help please update this post and I'll be happy to help.

Posted by Community Admin on 12-Jan-2012 00:00

Is there a recommendation for how to run a one-time script in Sitefinity, such as this, in which I want it to run exactly one time to pass my data to Sitefinity's API and then I will discard the code?

Posted by Community Admin on 12-Jan-2012 00:00

Julia,

the way I approach tasks like this is to simply use a temporary webforms page like import.aspx and in the code behind define everything I need to do. then I can run it, test everything then delete the file so it cannot be run again.

As long as you are running that page inside a Sitefinity application and include the necessary namespaces in the codebehind file you should have full access to the API.

hope this is helpful!

This thread is closed