Skip to main content
September 28, 2021
Question

save rating to database

  • September 28, 2021
  • 3 replies
  • 0 views

So I'm building a store in appian and i want the user to be able to rate a product and I want it saved so then ofter i can show an average rating of the product, what should I do in order to save the rating of the user in the database after i click the star icon or after i click a button to save the rating? i already have a database set up. Or if thats not possible is there any other way to do it?

    3 replies

    September 28, 2021

     a!sideBySideItem(
                item: a!richTextDisplayField(
                  label: "Rate the Product",
                  labelPosition: "ABOVE",
                  value: {
                    a!forEach(
                      items: enumerate(local!totalStars) + 1,
                      expression: {
                        a!richTextIcon(
                          icon: if(
                            fv!index <= local!rating,
                            "star",
                            "star-o"
                          ),
                          color: "ACCENT",
                          linkstyle: "STANDALONE",
                          link: a!dynamicLink(
                            value: if(local!rating=fv!index, 0, fv!index),
                            saveInto: local!rating
                          )

    I have this between the rest of the expressian

    csteward
    September 28, 2021

    I would suggest to review a!writeToDataStoreEntity(), which you can use in the saveInto of your a!dynamicLink to persist the selected rating to the DB.

    September 28, 2021

    will try it out thank you