1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Fluent API Form Examples?

Fluent API Form Examples?

21 posts, 0 answered
  1. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    18 Apr 2011
    Link to this post
    Could you give a few examples on how to use the Fluent API with forms?

    Queries needed:

     - List of form names
     - List of form entries for a particular form

    Thanks,

    Michael Snyder
    ConnectionsAcademy.com
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 Apr 2011
    Link to this post
    Hi ,

    You have to use the standard API to get these results.

                FormsManager manager = FormsManager.GetManager();
                var forms = manager.GetForms();
                foreach (FormDescription d in forms)
                {
                     var title = d.Title;
                      var name = d.Name;
                   
                }
    To get the response of a form you can use

    public IEnumerable GetFormEntries(Type entryType, string filter, string orderBy, int skip, int take, ref int? count)


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    20 Jun 2011
    Link to this post
    Hi,

    How do I add a value using Fluent API to the Form I created in CMS?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    20 Jun 2011
    Link to this post
    Hi Zubair,

    Here is the programmatic way to add a new entry to a form

    IManager manager;
    manager = FormsManager.GetManager(providerName);
     
    using (var fluent = App.WorkWith())
    {
        var facade = fluent.Forms().Form(formName);
        facade.Do(fd =>
        {
            fd.FormEntriesSeed++;
            entry.Item.ReferralCode = fd.FormEntriesSeed.ToString();
        });
     
    }
     
    entry.Item.SubmittedOn = DateTime.UtcNow;
    entry.Item.UserId = SecurityManager.GetCurrentUser().UserId;
    this.SetEntryIpAddress(entry.Item);
    manager.SaveChanges();
    ServiceUtility.DisableCache();


    Regards,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  5. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    20 Jun 2011
    Link to this post
    Hi,

    This is incomplete code and it breaks, can you please include full code with namespaces and also tell me how to add value for each form field?

    Thanks,
  6. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    21 Jun 2011
    Link to this post
    Hi,

    Any news?
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Jun 2011
    Link to this post
    Hi Zubair,

    Have you specified the form name for which you want to add a new entry? You can get a refernce to the classes through Visual Studio Intellisense. It should shows you the missing reference in your class.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  8. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    21 Jun 2011
    Link to this post
    I know I can add a FormName but I cant find out the how the entry will look like, anyway I will look at this post to do the same.
  9. Brett Winklesky
    Brett Winklesky avatar
    6 posts
    Registered:
    10 Dec 2009
    27 Jun 2011
    Link to this post
    @Ivan

    In your code posted on June 20th you are adding the "entry" data.  Where and how are you setting this up?

    entry.Item.SubmittedOn = DateTime.UtcNow;
    entry.Item.UserId = SecurityManager.GetCurrentUser().UserId;
    this.SetEntryIpAddress(entry.Item);
    manager.SaveChanges();
    ServiceUtility.DisableCache();

    I have tried to add a form entry using the sample code and it doesn't work on my end.  Do you guys have a full sample in the SDK? 

    Brett
  10. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    27 Jun 2011
    Link to this post
    @Brett,

    I got this to work with the help of this post, though I changed it from extension method to a 'normal' method

    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/how-to-use-createformentry.aspx#1567645

    Telerik/Sitefinity team isn't helping :(
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    28 Jun 2011
    Link to this post
    Hello,

    There is also FormEntriesFacade which could be used to get IQueryable<FormEntry>

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  12. Naman
    Naman avatar
    0 posts
    Registered:
    16 May 2017
    16 May in reply to Ivan Dimitrov
    Link to this post

    What are references are needed for this formsmanager. 

     

    Thanks 

    Naman 

  13. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    17 May in reply to Naman
    Link to this post

    If you want to use FormsManager, you need to add this using:

    using Telerik.Sitefinity.Modules.Forms;

     

  14. Naman
    Naman avatar
    0 posts
    Registered:
    16 May 2017
    17 May in reply to Victor Leontyev
    Link to this post

    Now what reference and dll is required for formsDescription ????

     

  15. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    17 May in reply to Naman
    Link to this post
    reference to Telerik.Sitefinity.dll 
  16. Naman
    Naman avatar
    0 posts
    Registered:
    16 May 2017
    17 May in reply to Naman
    Link to this post
    Still Getting Error for FormDescription ??? 
  17. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    17 May in reply to Naman
    Link to this post
    I cannot read your mind. Please give me more details. What is the error, your code and etc
  18. Naman
    Naman avatar
    0 posts
    Registered:
    16 May 2017
    17 May
    Link to this post

    FormsManager manager = FormsManager.GetManager();
                var forms = manager.GetForms();
                foreach (FormDescription d in forms)
                {
                    var title = d.Title;
                    var name = d.Name;

                }
                return View();

     

    Same code  I am using but on this line :-

    foreach (FormDescription d in forms)  

     

    getting error that FormDescription could not found (are you missing a using directive or an assembly reference) ???

  19. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    17 May in reply to Naman
    Link to this post

    add reference to Telerik.Sitefinity.Model.dll

    I am not sure why, you have missing references to this basic dlls in your project

  20. Naman
    Naman avatar
    0 posts
    Registered:
    16 May 2017
    17 May in reply to Naman
    Link to this post
    Thanks Its working now :)
  21. Naman
    Naman avatar
    0 posts
    Registered:
    16 May 2017
    18 May in reply to Ivan Dimitrov
    Link to this post
    Hi I need to ask if i am using this code in different application to get the form list from any website so how to pass website url in this code so can we get forms for that particular website. ? 
21 posts, 0 answered