More in this section

Forums / Developing with Sitefinity / Import data into module built with module builder

Import data into module built with module builder

4 posts, 1 answered
  1. Jules
    Jules avatar
    65 posts
    Registered:
    20 Jul 2005
    10 Jan 2012
    Link to this post
    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
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    10 Jan 2012
    Link to this post
    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.
    Answered
  3. Jules
    Jules avatar
    65 posts
    Registered:
    20 Jul 2005
    12 Jan 2012
    Link to this post
    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?
  4. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    12 Jan 2012
    Link to this post
    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!
4 posts, 1 answered