Partage via


Action msdyn_ForecastApi

En tant que développeur, utilisez cette documentation de référence pour utiliser l’action personnalisée msdyn_ForecastApi pour récupérer et mettre à jour les données de prévision.

Licences et rôles requis

Type de condition requise Vous devez disposer d’une
Licence Dynamics 365 Sales Premium ou Dynamics 365 Sales Enterprise
Pour plus d’informations : Tarification de Dynamics 365 Sales
Rôles de sécurité Personnalisateur du système
Pour plus d’informations : Rôles de sécurité prédéfinis pour Sales

Paramètres

Nom du paramètre Requise Description
WebApiName Oui Contient le nom de l’API à exécuter.
RequestJson Oui Contient les paramètres et les arguments de l’appel API.

Liste des API

Vous trouverez ci-dessous l’ensemble des API que vous pouvez invoquer à l’aide de l’action personnalisée msdyn_ForecastApi.

GET_ForecastConfigurations

Renvoie la liste de toutes les configurations de prévisions configurées.

Exemple

POST [Organization URI]/api/data/v9.1/msdyn_ForecastApi/ HTTP/1.1
Content-Type: application/json

{
    "WebApiName": "GET_ForecastConfigurations",
    "RequestJson": "{}"
}
Paramètre Type Description
WebApiName String Nom du API
RequestJson String Objet JSON sérialisé

Response

{
   "@odata.context": "[Organization URI]/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.msdyn_ForecastApiResponse",
   "response": [
      {
         "Columns": [
             {
                        "ForecastConfigurationColumnId": "0ad51075-912b-4e00-a7a1-91170e437d27",
                        ...
                        "ForecastConfigurationId": "27bd2c40-f868-ea11-a811-000d3a37bb2c",
                        ...
             },
             {
                        "ForecastConfigurationColumnId": "c3ef8024-6517-4168-adc7-bb5b520554a0",
                        ...
                        "ForecastConfigurationId": "27bd2c40-f868-ea11-a812-125d3a37bb2d",
                        ...
               
             }],
         "PermissionRoles": null,
         "AdditionalFilters": "<fetch version=\"1.0\" mapping=\"logical\"><entity name=\"opportunity\"><\/entity><\/fetch>",
         "IsSnapshotScheduled": false,
         "SnapshotSchedule": null,
         "SnapshotTimeZone": null,
         "PublishedDateTime": "0001-01-01T00:00:00",
         "DefaultViewIdForUnderlyingRecords": "bf649add-6c30-ea11-a813-000d3a5475f7"
      }
   ]
}

Valeur renvoyée

Liste des configurations de prévision

GET_ForecastConfigurationsByName

Renvoie toutes les configurations de prévision ayant le nom fourni dans le cadre de la charge utile de la demande.

Exemple

POST [Organization URI]/api/data/v9.1/msdyn_ForecastApi HTTP/1.1
Content-Type: application/json

{
    "WebApiName": "GET_ForecastConfigurationsByName",
    "RequestJson": "{\"Name\":\"api_test1\"}"
}
Paramètre Type Description
WebApiName String Nom du API
RequestJson Objet JSON Consiste en Name : nom de la configuration de prévision

Response

{
   "@odata.context": "[Organization URI]/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.msdyn_ForecastApiResponse",
   "response": [
      {
         "Columns": [
             {
                 "Name": "api_test1",
                 ...
                 "ForecastConfigurationId": "bcf37937-487e-ea11-a811-000d3a37bb2c",
                 ...
             }
         ],
         "PermissionRoles": null,
         "AdditionalFilters": "<fetch version=\"1.0\" mapping=\"logical\"><entity name=\"opportunity\"><\/entity><\/fetch>",
         "IsSnapshotScheduled": false,
         "SnapshotSchedule": null,
         "SnapshotTimeZone": null,
         "PublishedDateTime": "0001-01-01T00:00:00",
         "DefaultViewIdForUnderlyingRecords": "bf649add-6c30-ea11-a813-000d3a5475f7"
      }
   ]
}

Valeur renvoyée

Liste des configurations de prévision

GET_ForecastPeriodsByForecastConfigurationId

Renvoie toutes les périodes de prévision pour l’ID de configuration de prévision active, qui est fourni dans le cadre de la charge utile de la demande.

Exemple

POST [Organization URI]/api/data/v9.1/msdyn_ForecastApi HTTP/1.1
Content-Type: application/json

{
  "WebApiName": "GET_ForecastPeriodsByForecastConfigurationId",
  "RequestJson": "{
      \"ForecastConfigurationId\":\"04323a04-da7f-ea11-a811-000d3a37bb2c\"
      }"
}
Paramètre Type Description
WebApiName String Nom du API
RequestJson Objet JSON Contient ForecastConfigurationId : ID de configuration de la prévision

Response

{
   "@odata.context": "[Organization URI]/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.msdyn_ForecastApiResponse",
   "response": [
      {
         "Id": "8b8cadd8-ede3-4b21-97cf-93efc0337089",
         "ForecastConfigurationId": "04323a04-da7f-ea11-a811-000d3a37bb2c",
         "RecurrenceIndex": 0,
         "ValidFrom": "2020-04-01T00:00:00Z",
         "ValidTo": "2020-06-30T23:59:59Z",
         "Name": "FY2020 Q2",
         "RecomputeStatus": 10,
         "LastRecomputedOn": "2020-05-25T08:04:24.817Z",
         "RecomputationStartTime": "2020-06-05T05:04:30.904Z",
         "RecomputeStatusChangedOn": "2020-06-05T06:04:00.363Z",
         "FailureInfo": "Microsoft.Azure.WebJobs.FunctionFailedException: The activity function 'CreateUpdateForecastHierarchy' failed: \"An item with the same key has already been added. Key: b1d30f13-ce56-ea11-a812-000d3a382f93\". See the function execution logs for additional details. ---> System.ArgumentException: An item with the same key has already been added. Key: b1d30f13-ce56-ea11-a812-000d3a382f93\r\n   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)\r\n   at Microsoft.Dynamics.Forecasting.RecomputeEngine.HierarchyManager.<>c__DisplayClass23_0.<GetForecastInstancesByHierarchyEntityId>b__0(ForecastInstance forecastInstance) in C:\\src\\cloud_IDEs\\ide5\\Azure\\RecomputeEngine\\HierarchyManager\\HierarchyManager.cs:line 727\r\n   at System.Collections.Generic.List`1.ForEach(Action`1 action)\r\n   at Microsoft.Dynamics.Forecasting.RecomputeEngine.HierarchyManager.GetForecastInstancesByHierarchyEntityId(ForecastConfiguration forecastConfiguration, Guid forecastRecurrenceId) in C:\\src\\cloud_IDEs\\ide5\\Azure\\RecomputeEngine\\HierarchyManager\\HierarchyManager.cs:line 727\r\n   at Microsoft.Dynamics.Forecasting.RecomputeEngine.HierarchyManager.CreateOrUpdateForecastDataWithLatestHierarchy(ForecastConfiguration forecastConfiguration, Guid forecastRecurrenceId, Dictionary`2 latestHierarchyEntityList) in C:\\src\\cloud_IDEs\\ide5\\Azure\\RecomputeEngine\\HierarchyManager\\HierarchyManager.cs:line 602\r\n   at Microsoft.Dynamics.Forecasting.RecomputeEngine.HierarchyManager.<>c__DisplayClass16_0.<CreateOrUpdateForecastHierarchy>b__0() in C:\\src\\cloud_IDEs\\ide5\\Azure\\RecomputeEngine\\HierarchyManager\\HierarchyManager.cs:line 283\r\n   at System.Threading.Tasks.Task.InnerInvoke()\r\n   at System.Threading.Tasks.Task.<>c.<.cctor>b__275_1(Object obj)\r\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at Microsoft.Dynamics.Forecasting.RecomputeEngine.HierarchyManager.CreateOrUpdateForecastHierarchy(ForecastConfiguration forecastConfiguration, Guid forecastRecurrenceId, Dictionary`2 latestHierarchyEntityList) in C:\\src\\cloud_IDEs\\ide5\\Azure\\RecomputeEngine\\HierarchyManager\\HierarchyManager.cs:line 255\r\n   at Microsoft.Dynamics.Forecasting.RecomputeEngine.HierarchyManager.CreateOrUpdateForecastHierarchy(Guid orgId, Guid forecastConfigurationId, Guid forecastRecurrenceId, Dictionary`2 latestHierarchyEntityList) in C:\\src\\cloud_IDEs\\ide5\\Azure\\RecomputeEngine\\HierarchyManager\\HierarchyManager.cs:line 167\r\n   at Microsoft.Dynamics.Forecasting.AzureFunctions.CreateUpdateForecastHierarchy.Run(CreateUpdateForecastHierarchyInput input) in C:\\src\\cloud_IDEs\\ide5\\Azure\\AzureFunctions\\Recompute\\ActivityFunctions\\CreateUpdateForecastHierarchy.cs:line 43\r\n   at Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvoker`2.InvokeAsync(TReflected instance, Object[] arguments) in C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\VoidTaskMethodInvoker.cs:line 20\r\n   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync(Object instance, Object[] arguments) in C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionInvoker.cs:line 52\r\n   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker, ParameterHelper parameterHelper, CancellationTokenSource timeoutTokenSource, CancellationTokenSource functionCancellationTokenSource, Boolean throwOnTimeout, TimeSpan timerInterval, IFunctionInstance instance) in C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs:line 585\r\n   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstanceEx instance, ParameterHelper parameterHelper, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs:line 532\r\n   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx instance, ParameterHelper parameterHelper, IFunctionOutputDefinition outputDefinition, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs:line 468\r\n   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx instance, FunctionStartedMessage message, FunctionInstanceLogEntry instanceLogEntry, ParameterHelper parameterHelper, ILogger logger, CancellationToken cancellationToken) in C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs:line 278\r\n   --- End of inner exception stack trace ---\r\n   at Microsoft.Azure.WebJobs.DurableOrchestrationContext.CallDurableTaskFunctionAsync[TResult](String functionName, FunctionType functionType, String instanceId, RetryOptions retryOptions, Object input) in E:\\functions\\azure-functions-durable-extension\\src\\WebJobs.Extensions.DurableTask\\DurableOrchestrationContext.cs:line 498\r\n   at Microsoft.Dynamics.Forecasting.AzureFunctions.OrchestratorFunctionBase.ExecuteActivityAsync(DurableOrchestrationContext context, String functionName, Object input, Dictionary`2 telemetryProps) in C:\\src\\cloud_IDEs\\ide5\\Azure\\AzureFunctions\\OrchestratorFunctionBase.cs:line 252\r\n   at Microsoft.Dynamics.Forecasting.AzureFunctions.RecomputeOrchestrator.ExecuteRecomputeOrchestration(DurableOrchestrationContext context, RecomputeOrchestratorInput recomputeInput, String correlationId, Dictionary`2 telemetryProps) in C:\\src\\cloud_IDEs\\ide5\\Azure\\AzureFunctions\\Recompute\\RecomputeOrchestrator.cs:line 169",
         "RecurrenceState": 0,
         "UpdatedAttribteList": null
      }
    ]
}

Valeur renvoyée

Liste des périodes de prévision.

GET_ForecastInstances

Renvoie la liste des instances de prévision qui constituent un enregistrement d’entité à une seule ligne.

Note

Les périodes de prévision peuvent avoir de nombreuses instances de prévision. Bien plus que vous ne voudriez en retirer en une seule requête. Les points de terminaison de l’API fournissent par défaut un nombre limité d’éléments par demande.
Remarque : Les requêtes volumineuses peuvent affecter les performances. Le nombre de résultats par page est donc limité à 4 000 enregistrements. Si vous souhaitez récupérer plus de 4000 enregistrements, par exemple pour créer une liste côté client de toutes les instances de prévision disponibles, vous pouvez effectuer plusieurs requêtes API et combiner les résultats dans votre application.

Exemple

POST [Organization URI]/api/data/v9.1/msdyn_ForecastApi HTTP/1.1
Content-Type: application/json

{
    "WebApiName": "GET_ForecastInstances",
    "RequestJson": "{
    	\"ForecastPeriodId\":\"8b8cadd8-ede3-4b21-97cf-93efc0337089\",
    	\"ForecastConfigurationId\":\"04323a04-da7f-ea11-a811-000d3a37bb2c\", 
    	\"SortingAttribute\":\"HierarchyEntityRecord.RecordId\",
    	\"SortingOrder\":\"DSC\",
    	\"PageSize\":1,
    	\"PageNo\":1
    }"
}
Paramètre Type Description
WebApiName String Nom du API
RequestJson Objet JSON Se compose des éléments suivants
ForecastPeriodId : identificateur unique de la période de prévision
ForecastConfigurationId : identificateur unique de la configuration de prévision
SortingAttribute : l’attribut basé sur ce que vous souhaitez faire le tri dans la pagination
SortingOrder : ASC pour ordre croissant, DSC pour ordre décroissant
PageSize : nombre d’enregistrements que vous souhaitez récupérer sur une seule page
PageNo : les enregistrements de page que vous souhaitez récupérer.

Ci-dessous l’exemple JSON pour l’objet RequestJson.

{
    "WebApiName": "GET_ForecastInstances",
    "RequestJson": "{
    	\"ForecastPeriodId\":\"{{frid}}\",
    	\"ForecastConfigurationId\":\"{{fcid}}\", 
    	\"SortingAttribute\":\"HierarchyEntityRecord.RecordId\",
    	\"SortingOrder\":\"DSC\",
    	\"PageSize\":1,
    	\"PageNo\":1
    	
    }"
} 

Response

{
   "@odata.context": "[Organization URI]/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.msdyn_ForecastApiResponse",
   "response": {
      "ForecastInstances": [
          "ForecastInstanceId": "95d2305a-a0be-4b34-84ac-b10e67b0771a",
          "ForecastConfigurationId": "04323a04-da7f-ea11-a811-000d3a37bb2c",
            ...],
      "HasMorePages": false,
      "Code": 200,
      "Message": "OK"
   }
}

Valeur renvoyée

Liste des périodes de prévision.

Update_SimpleColumnByEntityId

Met à jour les valeurs de colonne spécifiques en définissant les valeurs des paramètres transmis.

Note

Un grand nombre de demandes de mise à jour dans un seul appel d’API peut nuire aux performances, de sorte que les mises à jour par demande sont plafonnées à 50.

Exemple

POST [Organization URI]/api/data/v9.1/msdyn_ForecastApi HTTP/1.1
content-type: application/json

{
    "WebApiName": "Update_ SimpleColumnByEntityId",
    "RequestJson": "
    {
      \"ForecastConfigurationId\":\"0461fb6b-8d85-ea11-a811-000d3a37bb2c\",
      \"ForecastRecurranceId\":\"f8b1122c-b913-4e88-9727-368b6134be3e\",
      \"SimpleColumnUpdateRequests\":[{
        \" HierarchyEntityRecordId\":\"d8680b00-fd31-46c2-8136-7c4df19cf2a8\",
        \"ForecastConfigurationColumnId\":\"65ec7bd1-2de6-49fa-b259-ba74bc721c78\",
        \"ForecastConfigurationColumnValue\":0.0,
        \"IsRolledUpColumnUpdate\":false},{
        \" HierarchyEntityRecordId\":\"11141300-131b-493a-9857-22bd8689b775\",
        \"ForecastConfigurationColumnId\":\"65ec7bd1-2de6-49fa-b259-ba74bc721c78\",
        \"ForecastConfigurationColumnValue\":0.0,
        \"IsRolledUpColumnUpdate\":false}]}"
}
Paramètre Nom  Description
WebApiName String Nom du API
ForecastConfigurationId GUID ID de configuration de prévision
ForecastRecurranceId GUID ID de récurrence de prévision ou ID de période de prévision Une liste de SimpleColumnUpdateRequests est un tableau
HierarchyEntityRecordId GUID EntityRecordId
ForecastConfigurationColumnId GUID ID de colonne de configuration de prévision
ForecastConfigurationColumnValue Type de données de ForecastConfigurationColumn Valeur qui doit être mise à jour pour
IsRolledUpColumnUpdate (facultatif) Entier True si la valeur est mise à jour pour la colonne cumulée, False si la valeur est mise à jour pour la colonne agrégée

Response

{
   "@odata.context": "[Organization URI]/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.msdyn_ForecastApiResponse",
   "response": [
      {
         "Message": "Update Successful",
         "StatusCode": 0,
         "HierarchyEntityRecordId": "d8680b00-fd31-46c2-8136-7c4df19cf2a8",
         "ForecastConfigurationColumnId": "65ec7bd1-2de6-49fa-b259-ba74bc721c78"
      },
      {
         "Message": "Update Successful",
         "StatusCode": 0,
         "HierarchyEntityRecordId": "11141300-131b-493a-9857-22bd8689b775",
         "ForecastConfigurationColumnId": "65ec7bd1-2de6-49fa-b259-ba74bc721c78"
      }
   ]
}

Valeur renvoyée

Une liste d’enregistrements UpdateSimpleColumnByEntityResponse se composant des éléments suivants : HierarchyEntityRecordId, ForecastConfigurationColumnId, Message, StatusCode.

Update_SimpleColumnByFIId

Met à jour la valeur de colonne spécifique en définissant les valeurs des paramètres transmis.

Note

Un grand nombre de demandes de mise à jour dans un seul appel d’API peut nuire aux performances, de sorte que les mises à jour par demande sont plafonnées à 50.

Exemple

POST [Organization URI]/api/data/v9.1/msdyn_ForecastApi HTTP/1.1
content-type: application/json

{
    "WebApiName": "Update_SimpleColumnByFIId",
    "RequestJson": "
    {
      \"ForecastConfigurationId\":\"0461fb6b-8d85-ea11-a811-000d3a37bb2c\",
      \"ForecastRecurranceId\":\"f8b1122c-b913-4e88-9727-368b6134be3e\",
      \"SimpleColumnUpdateRequests\":[
      {
        \"ForecastInstanceId\":\"d8680b00-fd31-46c2-8136-7c4df19cf2a8\",
        \"ForecastConfigurationColumnId\":\"65ec7bd1-2de6-49fa-b259-ba74bc721c78\",
        \"ForecastConfigurationColumnValue\":0.0,
        \"IsRolledUpColumnUpdate\":false},
        {
          \"ForecastInstanceId\":\"11141300-131b-493a-9857-22bd8689b775\",
          \"ForecastConfigurationColumnId\":\"65ec7bd1-2de6-49fa-b259-ba74bc721c78\",
          \"ForecastConfigurationColumnValue\":0.0,
          \"IsRolledUpColumnUpdate\":false}]}"
}
Paramètre Type Description
WebApiName String Nom du API
ForecastConfigurationId GUID ID de configuration de prévision
ForecastRecurranceId Guid ID de récurrence de prévision ou ID de période de prévision
SimpleColumnUpdateRequests Tableau Inclut les éléments suivants
ForecastInstanceId GUID ID de l’instance de prévision
ForecastConfigurationColumnId GUID ID de colonne de configuration de prévision
ForecastConfigurationColumnValue Type de données de ForecastConfigurationColumn Valeur qui doit être mise à jour pour
IsRolledUpColumnUpdate (facultatif) Entier True si la valeur est mise à jour pour la colonne cumulée, false si la valeur est mise à jour pour la colonne agrégée

Response

{
   "@odata.context": "[Organization URI]/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.msdyn_ForecastApiResponse",
   "response": [
      {
         "Message": "Update Successful",
         "StatusCode": 0,
         "ForecastInstanceId": "d8680b00-fd31-46c2-8136-7c4df19cf2a8",
         "ForecastConfigurationColumnId": "65ec7bd1-2de6-49fa-b259-ba74bc721c78"
      },
      {
         "Message": "Update Successful",
         "StatusCode": 0,
         "ForecastInstanceId": "11141300-131b-493a-9857-22bd8689b775",
         "ForecastConfigurationColumnId": "65ec7bd1-2de6-49fa-b259-ba74bc721c78"
      }
   ]
}

Valeur renvoyée

Une liste d’enregistrements UpdateSimpleColumnByEntityResponse se composant des éléments suivants : ForecastInstanceId, ForecastConfigurationColumnId, Message, StatusCode.

Voir aussi

Actions personnalisées pour les prévisions