Skip to main content
Known Participant
Sep 28, 2021 1:39 PM UTC
Question

save rating to database

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

    Known Participant
    Sep 28, 2021 2:28 PM UTC

     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
    Brainy
    Sep 28, 2021 3:12 PM UTC

    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.

    Known Participant
    Sep 28, 2021 3:26 PM UTC

    will try it out thank you