Ask a Dev
How stage / staging environment is populated?
I see in the docs many references to the staging environment, I have access to it, and I see that products and most of the configurations are the same as on the live environment.
I'm looking for information/docs that describe how a population of staging data happens when it happens, what will happen when I let's say change the product in the stage environment and then in a production environment, does the product on stage be overwritten?
Any Hints are helpful, thank you in advance.
Posted by Marcin Polak 4 days ago
Customizing Distributor Backoffice Pay History Page Results Using Extension Hooks
There are four hooks that impact the Pay History page data that returns: Your best bet is to use the Web Extension, connect ngrok, and connect each hook in Developer Tools -> Process Hooks to that endpoint, then modify . Look up "ngrok" in the developer site for more details.
# Associates.GetCommissionChecksHook
Using this hook, you can add actual checks to the returned list. For instance, if you want to show a reward point distribution that you kept track of, you could insert it into the list of CommissionCheck objects in the response.
# Commissions.GetCommissionCheckDetailsHook
This will allow you to modify or embellish Check Detail information. This includes updating info on contributors to the check. You'll see the list of Contributors on the page and in the Response object. This can be added to or updated.
# Commissions.GetCommissionBonusDetailsHook
This allows updates of contributors, additional bonus detail info, etc.
# Commissions.GetCommissionBonusDetailsAfterHook
This one impacts columns and values for the Commission Bonus Details. This includes Custom1 - Custom5, which are configurable in the Cloudspark (back office) admin. So, you could add specifics to a bonus and customize the layout to include those things, without touching Cloudspark custom code--just configuration. It's more about layout for this one.
Here's some code that shows how to mess with this one:
```csharp
using DirectScale.Disco.Extension.Hooks;
using DirectScale.Disco.Extension.Hooks.Commissions;
using DirectScale.Disco.Extension.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebExtension.Hooks.Commissions
{
public class GetCommissionBonusDetailsAfterHook : IHook\<AfterCommissionBonusDetailsHookModel, AfterCommissionBonusDetailsHookModel>
{
private readonly IAssociateService \_associateService;
public GetCommissionBonusDetailsAfterHook(IAssociateService associateService)
{
_associateService = associateService ?? throw new ArgumentNullException(nameof(associateService));
}
public async Task<AfterCommissionBonusDetailsHookModel> Invoke(AfterCommissionBonusDetailsHookModel request, Func<AfterCommissionBonusDetailsHookModel, Task<AfterCommissionBonusDetailsHookModel>> func)
{
foreach (var item in request.Detail)
{
var allColumns = new Dictionary<string, object>();
foreach (var column in item.Columns)
{
string valueToAdd;
switch (column.Key)
{
case "Other0":
valueToAdd = "Fred Flintstone";
break;
case "Other1":
valueToAdd = "Willma Flintstone";
break;
default:
valueToAdd = column.Value?.ToString();
break;
}
allColumns.Add(column.Key, valueToAdd);
}
item.Columns = allColumns;
}
var result = await func(request);
return result;
}
}
}
```
Posted by Russell Kloepfer 5 months ago
What are the possible options for statuses and types?
What are the possible options for Order.status, Package.Status, and Payment.Status, as well as Payment.PayType?
Posted by Josh Juncker 6 months ago
How to Pass Binary Placement Information via API?
# Question
How do I pass binary placement information via an API?
# Answer
For [custom content in **Cloudspark**](https://developers.directscale.com/docs/getting-started-with-front-end-development), the **NewApplication** object has a property named **Placements**. This property overrides the application placement that the caller can use to change the default placement during the enrollment process. DirectScale internal V1 and V2 APIs use the **NewApplication** object, but you can only call these from **CloudSpark**, not the Public API. The Public API has a version of the **Application** request object called [**CreateCustomer**](https://apigateway.directscale.com/docs/services/57fe6761cb00f20ae896cc68/operations/57fe7e33cb00f20ae896cc6b?); however, it does not expose the **Placements** property.
In short, the Client Extension [**Application** object](https://helpabstractions.directscale.com/api/DirectScale.Disco.Extension.Application.html?q=application) contains all of the information required to enroll a new Associate as well as upgrade an Associate from a Retail Customer to a Distributor. This object has the [**Placements** properties](https://helpabstractions.directscale.com/api/DirectScale.Disco.Extension.Placement.html). You will have to [create a custom API endpoint](https://developers.directscale.com/docs/example-custom-api) that calls the method on the service inside the Extension.
Posted by Learning Experience Team over 2 years ago
How does the Text Number field get set when you're creating the customer via the public API?
# Question
How does the **Text Number** field get set when you're creating the customer via the Public API?

# Answer
Using the [POST Create Customer](https://apigateway.directscale.com/docs/services/57fe6761cb00f20ae896cc68/operations/57fe7e33cb00f20ae896cc6b) endpoint, you can add the following field:
```json
"TextPhone": "+1 801 555-1111",
```
Read more about the Public API in [Public API Overview](https://developers.directscale.com/docs/public-api-overview)
Posted by Learning Experience Team over 2 years ago
Extension > Making Asynchronous Calls
# Question
What's the best way to make async calls in the Extension?
# Answer
When you have to call an async method, don't use `Task.Result`; instead, use this:
`.ConfigureAwait(false).GetAwaiter().GetResult()`
It looks terrible, but it's more reliable this way. `Task.Result` can lead to deadlocks.
Posted by Russell Kloepfer over 2 years ago
Custom Pages > How to access information about the current user
# Question
How can I access information about the currently logged-in user on a custom admin page?
# Answer
With Angularjs, you can inject the `adminService` and use the `getInfo()` function to get an object containing details about the current user.
```js
(function ()
{
module.controller( 'MyCustomController', MyCustomController );
MyCustomController.$inject = ['$scope', '$log', '$http', 'adminService'];
function MyCustomController( $scope, $log, $http, adminService)
{
adminService.getInfo().then(function(res) {
console.log(res.data);
});
}
} )();
```
Here we create a new controller called `MyCustomController` and specify to angular to include `adminService` in the injections. Once inside the controller function, we can then call `adminService.getInfo()` to get the http promise. The `res` object is the response, and the data about the user is in `res.data`. The structure of this data looks like this:
```
{
"BannerHtml": null,
"DataPoints": [...],
"Settings": { ... },
"User": {
"FirstName": "Joe",
"Id": 123456,
"IsDiscoUser": true,
"LastName": "Schmoe",
"RoleId": 100,
"Username": "myUserName"
},
"Permissions": ["ACTIVITY_LOG_VIEW", ... ]
}
```
The `data.User` object contains details related explicitly to the logged-in user, such as username, first and last name, and role ID.
Posted by Adam Hulet over 2 years ago
Extension > Costly SQL NVARCHAR Assumption when Using Dapper
Any time we filter in SQL on a VARCHAR column, it's best to send the parameter as an ANSI string. That way it can use the index more effectively. Dapper assumes NVARCHAR, and not all fields are NVARCHAR in Disco.
That looks like this:
```
var parameters = new
{
CommissionBeginDate = commissionBeginDate.Date,
CommissionEndDate = commissionEndDate.Date,
// BonusGroup = bonusGroup, // REPLACE with the line below
BonusGroup = new DbString { IsAnsi = true, Length = 100, Value = bonusGroup };
};
var query = @"Select AssociateID,Sum(Amount) Amount
From CRM_CommissionHistory
Where [Group] = @BonusGroup
And ComPeriodID in (Select recordnumber From CRM_CommissionPeriods
Where Begindate >= @CommissionBeginDate
And EndDate <= @CommissionEndDate
And PeriodName='ClientWeekly')
Group By AssociateID
";
return dbHelper.Query<AssociateTeamRoyaltyBonus>(query, parameters).ToList();
```
This will aid in the performance of the query. We mention it only because there are a lot expensive queries that go against the CRM_CommissionAssociateValues, CommissionPeriod, and Stats tables, that will benefit greatly from this addition.
Posted by Russell Kloepfer over 2 years ago
Q: Is there a way to see a list of datapoint filter names in the public apis?

To get a list of Data Point Filters, like the ones shown in the preceding example, you can use the [Get Data Point Categories](https://apigateway.directscale.com/docs/services/57fe6761cb00f20ae896cc68/operations/5be5fe055c40b04cea138665?&pattern=categories) call.
Request URL: `https://dsapi.directscale.com/v1/customers/datapoint-categories`
This list is also provided here: [Data Point Categories (GADP)](https://developers.directscale.com/docs/get-associate-data-points-gadp)
Posted by Learning Experience Team over 2 years ago
Commissions > How often does the system recalculate commissions? Is it on a new order? Or on a schedule? Does it recalculate only the open period or any un-locked period?
I got this from a client, and it's a common question.
Here's the answer:
For commissions, the system recalculates whenever there is a "commissionable event" (sale, sign-up, refund).
So, when an associate creates an order, they are put on the "stats queue". Then, any person impacted by that order is recalculated. Usually this takes 2 minutes for the average company (it changes some based on distributor count and comp plan complexity).
So, the updates are nearly real-time. The same is true for "projected commissions". If you look at the guts of the system, it's actually running independent stats jobs for current and future period stats.
It uses the comp plan to calculate stats. You can see the settings in the "Commission" section of Advanced Settings for a little more info on it.
Posted by Russell Kloepfer over 2 years ago