Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

Automatically assign coupon codes?

(0) ShareShare
ReportReport
Posted on by 97

Hello all!

I'm hoping one of you amazingly intelligent people can help me work out a problem. 

We occasionally send coupon codes to very specific segments of our users. For the purposes of the steps below, we basically have a standard Contact entity which has a relationship with our Codes entity. The current process to assign and send unique codes looks like this:

  1. We set up a static segment per specific marketing requirements
  2. We generate coupon codes externally, based on number of coupon codes needed for members in first step
  3. We pull down segment members from the Contact entity to grab a unique identifier
  4. We export a few previous entries from the Codes entity, just to use as a template
  5. We import back into the Codes entity, which links our generated coupon codes with a particular Contact by using the unique identifier
  6. We then use an each-if statement in a marketing email to send the unique coupon codes out via customer journey

This works great. However, I would like to be able to use this process with a dynamic segment. I imagine it looking like this:

  1. We set up a dynamic segment per specific marketing requirements
  2. We generate coupon codes externally, based on number of coupon codes needed for members in first step; we also generate an additional 20%, just for any new members that enter this segment while the associated customer journey is running
  3. We pull down current segment members from the Contact entity to grab a unique identifier
  4. We export a few previous entries from the Codes entity, just to use as a template
  5. We import back into the Codes entity, which links our generated coupon codes with a particular Contact by using the unique identifier; we also import the remaining 20% of coupon codes, but unlinked to any Contacts
  6. We then use an each-if statement in a marketing email to send the unique coupon codes out via customer journey

Then, when someone new enters the dynamic segment:

  1. Dynamics automatically chooses an unlinked entry in the Codes entity and links it to the new segment member (Contact).
  2. Dynamics then pushes the Contact through the live customer journey, which includes the email with the each-if unique coupon code.

My question is: Is there any way to make the last two steps happen automatically? Can Dynamics automatically assign coupon codes for people that enter a specific segment, either using the parameters laid out above, or another way? 

Thanks in advance for the help!

  • Cnquest Profile Picture
    Cnquest 97 on at
    RE: Automatically assign coupon codes?

    I take back my previous post; you are a wizard Leah Ju!

    Even though Step 2 would complete successfully, it what was causing the problem. To get it to work, and to hopefully make it easier for anyone else attempting this in the future, I did the following:

    • Set up step 1 exactly as outlined
      • Of note: for this particular flow, we have users sign up and capture a specific token. I used this field + specific token as part of my filter (example: contains(new_invitetoken,'tokenvalue').
    • Set up step 2 exactly as outlined
      • My "Filter rows" are where I was going wrong. Using the outputs from errors in Power Automate I was able to figure out what I was doing wrong. HOWEVER, I also ended up finding what I think is an easier way to filter. I created a test entry in my entity, then in Dynamics used Advanced Filters to find that value (and only that value). In Advanced Filters, you can pull down FetchXML. Download that, plug it into your "Fetch XML Query" in Power Automate and you're off to the races.
    • With step 2 properly configured, setup step 3 as outlined. 
      • Of note: We don't call our "contact" entity "contact"...but you want to use the actual plural name of this entity (example: "contacts") as Leah laid out, not the display name or plural of that name.

    So helpful...thanks!!

  • Cnquest Profile Picture
    Cnquest 97 on at
    RE: Automatically assign coupon codes?

    Thank you for this, Leah!

    I'm stuck on step 3, as my GUID for my Code entity does not display in Dynamic expressions. Do you know why this might be; some setting? Is there an expression to pull this instead?

  • Verified answer
    Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    RE: Automatically assign coupon codes?

    Hi Cnquest,

    Maybe you can use power automate to create one flow to link one code to one contact automatically.

    Based on you description, I still need your help to answer some questions:

    (1).Contact entity and Codes entity is 1:N relationship?

    (2).Links our generated coupon codes with a particular Contact by using the unique identifier, the unique identifier is contact Lookup field in the codes entity?

    Flow Steps:

    (1) Trigger---when a row is added, modified, or deleted

    https://learn.microsoft.com/en-us/power-automate/dataverse/create-update-delete-trigger 

    pastedimage1669184072280v1.png

    If a contact enters a specific dynamic segment, it means she meets the conditions you set in the dynamic segment, so you have to use the same filter in the flow

    pastedimage1669184141587v2.png

    2.List rows--Retrieve codes that unlinks any contacts to select anyone of them:

    https://learn.microsoft.com/en-us/power-automate/dataverse/list-rows 

    _lookuplogicname_value is format:

    pastedimage1669185903257v3.png

    3.Update a row--Using the contact guid to update lookup of the code:

    https://learn.microsoft.com/en-us/power-automate/dataverse/update

    pastedimage1669186082820v4.png

    Overview of the flow:

    pastedimage1669186129619v5.png

    Another suggestion:

    Add 'wait for' action in the customer journey, which ensures that the flow can be executed first

    pastedimage1669186238378v6.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans