jbonfardeci / ShockoutForms

SharePoint + Knockout MVVM forms - an InfoPath killer
32 stars 8 forks source link

Use without a custom master page #12

Closed TotallyInformation closed 8 years ago

TotallyInformation commented 8 years ago

Hi, I'm trying to use ShockoutForms without using a custom master page as per current Microsoft guidelines on SharePoint Online development.

I've started by simply putting a script webpart in the default newform. However, I keep getting an error box saying:

An error has occurred and the web administrator has been notified.
Failed to retrieve list data. error: Internal Server Error

Is there some other way to approach this?

jbonfardeci commented 8 years ago

This error dialog will appear unless you put the form into debug mode by setting the options debug property to true. Setting debug to true will prevent the error from being written to the Error Log list (if you have one setup) and display errors messages in there developer console. However you can only use Shockout with KnockoutJS markup, it will not work with the SharePoint New Form template. Shockout is intended for those who want to take advantage of SharePoint SOAP and REST services and modern MVC/VM paradigms, bypassing SharePoint's antiquated and clunky forms. You don't have to use a custom master page, but I'd recommend it. Please see the examples directory in the GitHub repository for how to add the CSS and JavaScript src files in the correct order as well as Knockout markup examples. Shockout doesn't auto generate the field elements for you but it is planned for the next release. Please let me know if I can answer any more questions.

TotallyInformation commented 8 years ago

Thanks a lot for your response and thanks for clarifying the approach. This isn't quite what I was after at present but I understand now.

One comment I would make however, is that Microsoft are strongly recommending moving away from custom master pages & we've seen ourselves that they can cause major issues given how rapidly Microsoft are changing the underlying technologies.

All the best for this project and I will revisit from time to time to see how it gets on.

jbonfardeci commented 8 years ago

Thank you for your interest and I appreciate the information. Good thing one can use this framework with the default master pages. Shockout will turn any element container into a web form based on your SharePoint list. For our environment, we store all of our company forms in a Forms Document Library with read-only permissions, and I use a custom master page since the extra SharePoint CSS and JS is unnecessary overhead. All user validation is done with SOAP and/or REST. Sometimes SharePoint CSS gets in the way of your own CSS but it just takes a little more work to create good overrides. What makes this framework powerful is our ability to set group permissions on elements such as manager approval sections and to create special rules, via KnockoutJS, for showing/hiding dependent fields. For example, if a selected menu option dictates that another field or more are required, Knockout will add them to the DOM and set the field attributes to required. This can be done with InfoPath but the management of rules within InfoPath Designer is arduous. Plus, as our requirements are quite complex, Shockout provides a callback for adding your own custom logic such as reading related list items from an external list. This is difficult to do with custom XSLT forms or even InfoPath; Shockout provides a consistent pattern for performing these tasks repeatedly.

On Wed, Apr 20, 2016 at 8:15 AM, Julian Knight notifications@github.com wrote:

Thanks a lot for your response and thanks for clarifying the approach. This isn't quite what I was after at present but I understand now.

One comment I would make however, is that Microsoft are strongly recommending moving away from custom master pages & we've seen ourselves that they can cause major issues given how rapidly Microsoft are changing the underlying technologies.

All the best for this project and I will revisit from time to time to see how it gets on.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/jbonfardeci/ShockoutForms/issues/12#issuecomment-212419163

John Bonfardeci .-. |o,o| ,| \=/ .-""-. ||/_/_\ /[] \ |/|()|\ |_oLII| ../// / | ==== | \ |_/|"` || ==== || ||| ||" || || |-|-| ||LI o || ||| ||'----'|| // _\ /| |\

TotallyInformation commented 8 years ago

Thanks for taking the time to respond. You certainly have an interesting approach and I'll give it some more thought. In our case, I'm desperately trying to reduce the overheads for producing line-of-business applications while trying to encourage business users away from Excel/Access solutions.

We have very little developer resource so I'm concentrating on tools that enable business users to do more. We also have very little admin resource and having custom master pages adds significant overheads since SharePoint Online is changing so rapidly.

I'll live with the overheads that the standard SP pages bring because I want to keep things as standard as possible. What would be really nice would be to have a single aspx page for a lists form with read/edit/new functions controlled dynamically and using REACT and Foundation or Bootstrap.

jbonfardeci commented 8 years ago

I certainly sympathize. For 6 years working for a nonprofit, I was the sole developer managing our SP farm, writing websites, and all sorts of custom applications related to billing and compliance as it relates to health care. I was spread very thin and working tons of overtime. I wrote Shockout to make writing forms more efficient and to meet the needs of my users who expect SP to provide features you'd find in modern web applications. Our IT provider rapes us in revenue so there's not much left over for developers and no one could even find the time to learn InfoPath. For the next version of Shockout, I am writing a form generator to create the source code for you based on a list you point it to. At first I was just thinking of doing this with a JavaScript generator where you'd have to copy and paste the code into a new page, but you have me thinking about non-developers now. Theoretically, I could write a web part that not only generates the source code but creates an ASPX page based on a master page of your choosing. This may fulfill your goal of enabling your users to create their own forms - that is if they learn how to create a custom list and add the appropriate columns, types, etc. For now Shockout enables me to create custom, complex forms in a fraction of the time it used to take me. I'll write up some examples of forms based on standard master pages and post them in the examples directory ASAP.

FYI, for custom SP applications, dashboards, I normally write single-page applications with AngularJS in TypeScript. I wrote a library of essential CRUD methods I can plug into any app. I've been interested in learning React but Angular fulfills my needs quite nicely for now and I'm studying about 6 other subjects at this time. I used KnockoutJS for Shockout just because I felt Angular was overkill for it.

TotallyInformation commented 8 years ago

Wow! You've been busy. And you've really given me some things to think about. I'm afraid that development is only a sideline for me as I am responsible for the overall technical and security architectures for the organisation.

Some additional examples would be very useful indeed and would probably give me the start I need to have a go at following your pattern.

Of course, a form builder would be even better! Even if you were to make form building accessible to power users - e.g. those who are capable of creating complex spreadsheets with some macro's - that would be a tremendous step in the right direction.

Going further, there is certainly a gap in the market for a set of tools for building UI's and line-of-business apps for SharePoint. I can see from your code the value of using Knockout and I agree that some of the tools are overly complex. I built an app a while ago using Angular and I swore I wouldn't put myself through the pain again! That's one of the reasons I started looking at REACT but even that is overkill for many uses. For a home project, I actually wrote my own simplistic SPA framework (no routing or anything like that, just a dynamic form) using a combination of Zurb Foundation and websockets. Even doing that was easier than trying to learn some of the frameworks.

Anyway, I like your ideas and look forward to seeing future developments.