Not able to create automaticAppDiscount due to "title must be unique" error

Solved
raj_asha
Shopify Partner
5 0 0

Hi,

When I try to run the mutation to create automaticAppDiscount - https://shopify.dev/docs/api/admin-graphql/2023-07/mutations/discountAutomaticAppCreate I get an error that:

"data": {
        "discountAutomaticAppCreate": {
            "automaticAppDiscount": null,
            "userErrors": [
                {
                    "field": [
                        "automaticAppDiscount",
                        "title"
                    ],
                    "message": "must be unique"
                }
            ]
        }
    },

But there is no discount with that name on the store when I run the automaticDiscountNodes query - https://shopify.dev/docs/api/admin-graphql/2023-07/queries/automaticDiscountNodes:

    "data": {
        "automaticDiscountNodes": {
            "edges": [
                {
                    "node": {
                        "automaticDiscount": {
                            "__typename": "DiscountAutomaticBxgy",
                            "title": "Buy one, get the second 10 percent off"
                        }
                    }
                },
                {
                    "node": {
                        "automaticDiscount": {
                            "__typename": "DiscountAutomaticBasic",
                            "title": "Buy three, get 30 percent off"
                        }
                    }
                }
            ]
        }
    },

 

Why is it then preventing me from creating a new discount with the error - title must be unique?

Accepted Solution (1)
topshop
Shopify Partner
30 4 5

This is an accepted solution.

I ran into this in one of my development stores. My best guess is that you might have created a discount with the title / code in question with a previous function that I had created. But when you delete that function and pushed out another function, the old discount is in the system, but doesn't show up in the UI because the old function is no more. Again, this is just my guess.

View solution in original post

Replies 2 (2)
topshop
Shopify Partner
30 4 5

This is an accepted solution.

I ran into this in one of my development stores. My best guess is that you might have created a discount with the title / code in question with a previous function that I had created. But when you delete that function and pushed out another function, the old discount is in the system, but doesn't show up in the UI because the old function is no more. Again, this is just my guess.

raj_asha
Shopify Partner
5 0 0

Thanks for the reply. I think this could be the reason since I had a lot of functions deployed so due to the new simplified deployment, I think my actual function got deleted and some other function got activated in its place and because of this the discount associated with the old function also disappeared from the dashboard.