Fluent API Form Examples? - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Fluent API Form Examples?

  • Fluent API Form Examples?
  • 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
  • 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 >>
  • Hi,

    How do I add a value using Fluent API to the Form I created in CMS?
  • 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 >>
  • 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,
  • Hi,

    Any news?
  • 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 >>
  • 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.
  • @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
  • @Brett,

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

    www.sitefinity.com/.../how-to-use-createformentry.aspx

    Telerik/Sitefinity team isn't helping :(
  • 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 >>
  • What are references are needed for this formsmanager. 

     

    Thanks 

    Naman 

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

    using Telerik.Sitefinity.Modules.Forms;

     

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