Tip #1003: Gamification Workflow Assemblies and Plugins

After you enable Gamification in Dynamics 365, you will notice a new category of workflow steps available to you.

These workflows may be useful to you in controlling how Gamification works (such as automatically triggering KPI rollups, disabling KPI’s, etc), and some of them may be useful for other purposes (stop all running workflows). The following is a brief description of the workflows and plugins provided with the Gamification solution:


Retrieves Sales Metrics where  game.startdate <= DateTime.Now and game.enddate >= DateTime.Now. Retrieves Data markers and create process and job records of type retrieve.


– Retrieve new Aggregation Values using FetchXML (Group by Sales Metric Id, Player Id, filter by specific date and sales metric ids of updated individual metric records)

– Update Player Data Records using aggregated values in transaction

–  If it is not last page -> create Calculation job for next page

– Mark current job for deletion


Authenticates the cloud end point and schedules the SendUserWf and PredefinedKPIInitializationWf to run.


– If it is Player Data Records Job

Retrieve Player Data Records related to appropriate sales metric

Mark records for deletion

If it is not last page -> create Reset job for next page

If it is the last page -> create Reset job for Interim Records

Mark current job for deletion

– Else (it is Interim Records Job)

Retrieve Interim Records related to appropriate sales metric

Mark records for deletion

If it is not last page -> create Reset job for next page

Mark current job for deletion


Deletes data metrics, jobs, processes, player data, interim records.


Detects duplicates in Games, Player or Metric data.


– Create new Data Process

– Create Data Job

– Run Job


Retrieves the CRM server version.


Retrieves the organization name.


Get midnight marker. Trigger on create of settings

=> Wait for next settings.NextDataMarkerTrackerWFRun

=> Create empty data marker

=> Retrieve changes for data marker using last saved data marker

=> Backup new midnight marker

=> update next run value (+1 day)

=> trigger itself


Get games, players and metrics from Azure. Trigger on first authorize on the Login/Register page. Runs daily midnight

=> Wait until settings.NextFSTDailySyncDate

=> Retrieves data from cloud and update CRM records if needed

=> Update NextFSTDailySyncDate+1 day

=> triggers a child workflow (itself)


Retrieves changes related to an entity based on the data marker.


– If it is Player Data Records Job

Retrieve Updated Player Data Records

Drop IsUpdated flag

If it is not last page -> create Drop Flags job for next page

If it is the last page -> create Drop Flags job for Interim Records

Mark current job for deletion

– Else (it is Interim Records Job)

Retrieve Updated Interim Records

Drop IsUpdated flag

If it is not last page -> create Drop Flags job for next page

Mark current job for deletion


On change in Game start date end date drops the existing data markers and stops any metric handling running processes or jobs and resets all metrics.


Updates game start and end date.


Gets Gamifications jobs that are in running state.


Resets all Gamification jobs.


Retrieves Gamification settings.


Checks if a process is running or not.


Resets entity markers related to all metrics.


– Commit markers

– Drop FullPostFlag if exist

– Drop Sales Metrics Reset Flag

– Set settings.IsCalculationRunning to false


On Demand. Launch calculation iteration

=> Retrieve set sales metrics where related game.startdate <= DateTime.Now and game.enddate >= DateTime.Now

=> Retrieve current data markers

=> If exist

– Create process record (Type – Retrieve)

– For each entity type of retrieved sales metric, create a Job record related to process record with appropriate marker

=> Set state of N created job (N – settings.ThrottleNumber) to Run => start Gamification Worker


Resets game metric feeds.


Creates out of box KPI’s


Disables entity related KPI’s.


Deletes KPI data on the cloud side based on the metric feed ID.


Checks if there are any active games running corresponding to the KPI data that is currently being deleted. If they are this will throw an exception.


Send KPI information to cloud side.


Fetches KPI information from the cloud side and syncs it on the CRM side.


Activates/Deactivates KPI’s on CRM side.


Send new users created to cloud.


Schedules the next job in the process which is in ready state to run.


=> Runs every 6 hrs

=> Checks state of processes

=> Log the failure and restart processes as needed


Map players to users.


Retrieves midnight markers from cloud side.


Retrieves metrics from cloud.


=> Create a Scheduled process

=> Start it running


Send change tracking disabled notification to Gamification cloud end point.


– Retrieve updated player data records

– Post data to Azure

– If it is not last page -> create Data Sending job for next page

– Mark current job for deletion


Resets the metric data on the cloud side.


=> Get all active users in CRM  which have valid first name, last name, email address

=> Send the users to cloud


Creates and update GamificationSettings entity.


Starts on activation, controls when the calculation should run

=> Wait until settings.NextStarterWFRun

=> Retrieve games where related game.startdate <= DateTime.Now and game.enddate >= DateTime.Now

=> If games exist

– Run child workflow (FST Scheduler WF)

– Update settings. NextStarterWFRun (game.enddate + 1day if no overlap, or max(game.enddate) + 1 day if overlaps

=> Else

– Update settings. NextStarterWFRun (+1 day)

=> Run child workflow (itself)


Stops all gamification processes.


Stops all running processes and jobs.


This sends out telemetry information periodically.


Sets time out for gamification operations.


Logs exception trace and throws plugin exception.


Sends App version information to Cloud end point


– Retrieve entity changes using marker (appropriate page)

– If CT retrieve failed

Send request to Azure (CT failed)

Set settings.CTDisabled to true

Mark current job for deletion

Exit from WF

– Retrieve sales metrics based on specific entity type

– Retrieve players based on sales metrics

– Apply sales metrics filters to retrieved records (Get FetchXML from sales metric, add “IN (retrieved records   ids)” condition to id)

– Update Individual Metric Records (for retrieved records) using ExecuteTransaction

– If it is the last page

Update entity marker

– Else

Create new job with the same entity name and marker, but with next page

– Mark current job for deletion


Leave a Reply

Your email address will not be published. Required fields are marked *