More in this section
Forums / Developing with Sitefinity / Creating Dynamic content and set parent not working

Creating Dynamic content and set parent not working

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Anju
    Anju avatar
    19 posts
    22 Jul 2014
    08 Oct 2015
    Link to this post


    I am trying to create a dashboard widget to import data from a CSV to a dynamic content which is in a hierarchical pattern. 

    I have manually created the parent dynamic content and in my widget i use a dropdown to select the parent content and upload the CSV to create the data a child of that particular Parent. 

    Please find the code i have used for creating dynamic content through API's.

     public void CreateChildContentFromCSV(Record csvDataObj,Guid parentId)
                DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(Constants.ConstantVariables.ProviderName);
                DynamicContent dataContentItem = dynamicModuleManager.CreateDataItem(Constants.ModuleTypes.dataContentItemType);

                // Set item parent
                Type admissionType = Constants.ModuleTypes.admissionType;
                dataContentItem .SetParent(parentId, admissionType.FullName);

                // This is how values for the properties are set
                dataContentItem .SetValue("Title", licensure.LicensureTitle);
                licensureItem.SetValue("Description", licensure.Description);
                string UrlName = Regex.Replace(licensure.LicensureTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
                licensureItem.SetString("UrlName", UrlName);
                licensureItem.SetValue("Owner", SecurityManager.GetCurrentUserId());
                licensureItem.SetValue("PublicationDate", DateTime.Now.ToUniversalTime());

                ILifecycleDataItem publishedItem = dynamicModuleManager.Lifecycle.Publish(dataContentItem);
                licensureItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Published");


    I am getting the content created but only the parent is not set. When i set it manually it works. Can somebody help me figure out what am i doing wrong? 


1 posts, 0 answered