Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

While using APIerSv2.SetAccount , ActionPlanIDs is not getting linked with Account

93 views
Skip to first unread message

mfaisa...@gmail.com

unread,
Jan 18, 2025, 6:58:51 PMJan 18
to CGRateS
Hi Team,
if "APIerSv2.SetAccount" is used to create account ActionPlanIDs is not getting linked with account: 1004 
{
    "method": "APIerSv2.SetAccount",
    "params": [
        {
            "Tenant": "cgrates.org",
            "Account": "1004",
            "ActionPlanIDs": ["AP_PACKAGE_10"],
            "ReloadScheduler": true,
            "AllowNegative": false,
            "Disabled": false,
            "ActionTriggerOverwrite": true,
            "ActionPlansOverwrite": true,
            "ActionTriggerIDs": [
                "STANDARD_TRIGGERS"
            ]
        }
    ]
}

checking using:
Requst:
{
    "method": "APIerSv1.GetAccountActionPlan",
    "params": [
        {
            "Tenant": "cgrates.org",
            "Account": "1004"
        }
    ]
}

Result:
{
    "id": null,
    "result": [],
    "error": null
}
can be seen in mongodb:
but value Array is empty:
value.jpg

Account is created successfully and "STANDARD_TRIGGERS" applied:
{
    "id": null,
    "result": {
        "ID": "cgrates.org:1004",
        "BalanceMap": {
            "*monetary": [
                {
                    "Uuid": "aba5755b-08fd-457a-abb9-c7223e127fce",
                    "ID": "test",
                    "Value": 10,
                    "ExpirationDate": "0001-01-01T00:00:00Z",
                    "Weight": 10,
                    "DestinationIDs": {},
                    "RatingSubject": "",
                    "Categories": {},
                    "SharedGroups": {},
                    "Timings": null,
                    "TimingIDs": {},
                    "Disabled": false,
                    "Factors": null,
                    "Blocker": false
                }
            ]
        },
        "UnitCounters": null,
        "ActionTriggers": [
            {
                "ID": "STANDARD_TRIGGERS",
                "UniqueID": "1958ea08-e483-44c5-9335-c87fe1ab804b",
                "ThresholdType": "*max_balance",
                "ThresholdValue": 20,
                "Recurrent": false,
                "MinSleep": 0,
                "ExpirationDate": "0001-01-01T00:00:00Z",
                "ActivationDate": "0001-01-01T00:00:00Z",
                "Balance": {
                    "Uuid": null,
                    "ID": null,
                    "Type": "*monetary",
                    "Value": null,
                    "ExpirationDate": null,
                    "Weight": null,
                    "DestinationIDs": null,
                    "RatingSubject": null,
                    "Categories": null,
                    "SharedGroups": null,
                    "TimingIDs": null,
                    "Timings": null,
                    "Disabled": null,
                    "Factors": null,
                    "Blocker": null
                },
                "Weight": 10,
                "ActionsID": "ACT_LOG_WARNING",
                "MinQueuedItems": 0,
                "Executed": false,
                "LastExecutionTime": "0001-01-01T00:00:00Z"
            },
            {
                "ID": "STANDARD_TRIGGERS",
                "UniqueID": "ba2ebb15-5a23-4089-be04-914beeb499a5",
                "ThresholdType": "*max_balance",
                "ThresholdValue": 100,
                "Recurrent": false,
                "MinSleep": 0,
                "ExpirationDate": "0001-01-01T00:00:00Z",
                "ActivationDate": "0001-01-01T00:00:00Z",
                "Balance": {
                    "Uuid": null,
                    "ID": null,
                    "Type": "*monetary",
                    "Value": null,
                    "ExpirationDate": null,
                    "Weight": null,
                    "DestinationIDs": null,
                    "RatingSubject": null,
                    "Categories": null,
                    "SharedGroups": null,
                    "TimingIDs": null,
                    "Timings": null,
                    "Disabled": null,
                    "Factors": null,
                    "Blocker": null
                },
                "Weight": 10,
                "ActionsID": "DISABLE_AND_LOG",
                "MinQueuedItems": 0,
                "Executed": false,
                "LastExecutionTime": "0001-01-01T00:00:00Z"
            }
        ],
        "AllowNegative": false,
        "Disabled": false,
        "UpdateTime": "2025-01-18T23:40:45.108Z"
    },
    "error": null
}

if I use: APIerSv1.SetAccount
{
    "method": "APIerSv1.SetAccount",
    "params": [
        {
            "Tenant": "cgrates.org",
            "Account": "1004",
            "ActionPlanID":"AP_PACKAGE_04",
            "ActionTriggerIDs":"STANDARD_TRIGGERS",
            "ExtraOptions": null,
            "ReloadScheduler": true  
        }
    ]
}

Then ActionPlan: AP_PACKAGE_04 is applied but ActionTriggerID is not applied
mongodb snapshots:
value-1.jpg
ActionTriggerID null
actiontrigger.jpg

Kindly look into the issue

Regards,
Faisal Sharif





Armir Veliaj

unread,
Jan 23, 2025, 11:23:26 AMJan 23
to CGRateS
Hi Faisal,

If your ActionPlan is configured to execute *asap, its actions are executed immediately and then removed from the scheduler queue. As a result, these actions will not be included in the response of the GET API.

In case if this does not apply to your ActionPlan configuration, please provide all relevant requests such as SetActionPlans, SetActions, and any related CSV files for further investigation.

Thanks,
Armir

Faisal Sharif

unread,
Jan 24, 2025, 4:07:28 PMJan 24
to CGRateS
Dear Armir,
It seems behavior of APIerSv1.SetAccount and APIerSv2.SetAccount is not consistent while applying ActionPlan.
If ActionPlan with "Time": "*asap" is used while creating account using APIerSv1.SetAccount. APIerSv1.GetAccountActionPlan returns value:

Here are calls:
API call to SetActionPlan:

{
    "method": "APIerSv1.SetActionPlan",
    "params": [
        {
            "Id": "AP_ACT_TOPUP_RST_04",
            "ReloadScheduler": true,
            "Overwrite": true,
            "ActionPlan": [
                {
                    "ActionsId": "ACT_TOPUP_RST_04",
                    "MonthDays": "*any",
                    "Years": "*any",
                    "WeekDays": "*any",
                    "Months": "*any",
                    "Time": "*asap",
                    "Weight": 10
                }
            ]
        }
    ]
}
    

API call to create account using APIerSv1.SetAccount :
{
    "method": "APIerSv1.SetAccount",
    "params": [
        {
            "Tenant": "cgrates.org",
            "Account": "1004",
            "ActionPlanID":"AP_ACT_TOPUP_RST_04",
            "ActionTriggerID":"STANDARD_TRIGGERS",
            "ExtraOptions": null,
            "ReloadScheduler": true  
        }
    ]
}
Result: OK

Request to Get Account action plan:
{
    "method": "APIerSv1.GetAccountActionPlan",
    "params": [
        {
            "Tenant": "cgrates.org",
            "Account": "1004"
        }
    ]
}

Response:
{
    "id": null,
    "result": [
        {
            "ActionPlanId": "AP_ACT_TOPUP_RST_04",
            "Uuid": "c432b7a8-601d-4465-a635-6c6fdc2eff75",
            "ActionsId": "ACT_TOPUP_RST_04",
            "NextExecTime": "2025-01-25T01:47:49+05:00"
        }
    ],
    "error": null
}
==============================================
Now if I create account: 1007 using  "APIerSv2.SetAccount" with same ActionPlan: AP_ACT_TOPUP_RST_04 (created above)

{
    "id":2,
    "method": "APIerSv2.SetAccount",
    "params": [
        {
            "Tenant": "cgrates.org",
            "Account": "1007",
            "ActionPlanIDs": ["AP_ACT_TOPUP_RST_04"],
            "ActionPlansOverwrite": true,
            "ActionTriggerIDs": ["STANDARD_TRIGGERS"],
            "ActionTriggerOverwrite": true,
            "ExtraOptions": {
               "AllowNegative": true,
               "Disabled": true
            },
            "ReloadScheduler": true
        }
    ]
}

Result: OK
But there will be no value APIerSv1.GetAccountActionPlan

Request:
{
    "method": "APIerSv1.GetAccountActionPlan",
    "params": [
        {
            "Tenant": "cgrates.org",
            "Account": "1007"
        }
    ]
}

Response:
{
    "id": null,
    "result": [],
    "error": null
}

==========================
It is true if Time is set to "Time":"00:00:00" other than "Time": "*asap" , Account Action plan is set to AP_ACT_TOPUP_RST_04, but it doesnt serve the purpose. Account will not appear under APIerSv1.GetActionPlan

Thanks,
Faisal Sharif









 






























Yes during creation of ActionPlan using  APIerSv1.SetActionPlan with  "Time": "*asap" it gets removed.  if I set "Time:00:00:00". Applied action plan is returned when when APIerSv1.GetAccountActionPlan is executed.






From: cgr...@googlegroups.com <cgr...@googlegroups.com> on behalf of Armir Veliaj <armir....@itsyscom.com>
Sent: Thursday, January 23, 2025 9:23 PM
To: CGRateS <cgr...@googlegroups.com>
Subject: Re: While using APIerSv2.SetAccount , ActionPlanIDs is not getting linked with Account
 
--
You received this message because you are subscribed to the Google Groups "CGRateS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cgrates+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cgrates/946483da-fa50-4195-b989-c13c5ac95be2n%40googlegroups.com.

Faisal Sharif

unread,
Jan 25, 2025, 5:51:49 PMJan 25
to CGRateS, Armir Veliaj, dan....@itsyscom.com
Hi Armir,
Please share your opinion. When account is created using APIerSv2.SetAccount. Applied ActionPlan value should be retained in account_action_plans similar to when account is created  APIerSv1.SetAccount
API call examples are in below email.
Also please note that while creating account using APIerSv1.SetAccount, ActionTriggerID is not applied on the account. I am using latest version of CGRateS on Debian 12-bookworm.

Thanks,
Faisal Sharif

From: Faisal Sharif <mfaisa...@gmail.com>
Sent: Saturday, January 25, 2025 2:07 AM

Armir Veliaj

unread,
Jan 29, 2025, 9:42:02 AMJan 29
to CGRateS
Hi Faisal,

The inconsistency you observed between APIerSv1.SetAccount and APIerSv2.SetAccount is intentional, based on their design. In both APIs, the actions are executed, but the difference is that when the timing is set to *asap in APIerSv2.SetAccount, the ActionPlan executes but doesn't get stored in the AccountActionPlan structure. While in APIerSv1.SetAccount, it executes and stores the ActionPlan; however, it becomes unusable afterward because the NextExecTime is past the current real-time.

I hope this clarifies things for you.

Thanks,
Armir

Faisal Sharif

unread,
Jan 29, 2025, 4:41:40 PMJan 29
to CGRateS
Dear Armir,
Thanks for clarification.

Regards,
Faisal


Sent: Wednesday, January 29, 2025 7:42 PM
Reply all
Reply to author
Forward
0 new messages