cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Action Won't Work inside Action Card

Mmckinst
7 - Data Storage
7 - Data Storage

Hi all,

 

I'm trying hide my input parameters in an action card. However, my "Apply" button doesn't seem to work while it's inside the card. Does any one know how I could get this working? 

*The action works just fine when it's not inside an action card.

Find my Blox Code and Action Code below:

Blox:

 

{
    "style": "",
    "script": "",
    "title": "",
    "titleStyle": [
        {
            "display": "none"
        }
    ],
    "showCarousel": true,
    "body": [
        {
            "type": "Container",
            "items": [
                {
                    "type": "Container",
                    "spacing": "none",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "Monday",
                            "size": "extraLarge",
                            "color": "attention",
                            "spacing": "none",
                            "horizontalAlignment": "center"
                        }
                    ]
                },
                {
                    "type": "Container",
                    "separator": "true",
                    "spacing": "medium",
                    "items": [
                        {
                            "spacing": "none",
                            "type": "ColumnSet",
                            "columns": [
                                {
                                    "spacing": "medium",
                                    "separator": "true",
                                    "type": "Column",
                                    "items": [
                                        {
                                            "type": "TextBlock",
                                            "horizontalAlignment": "left",
                                            "text": "Morning Standing",
                                            "color": "blue",
                                            "size": "small"
                                        },
                                        {
                                            "spacing": "none",
                                            "horizontalAlignment": "left",
                                            "type": "TextBlock",
                                            "text": "{panel:[monStanding]}",
                                            "weight": "bold",
                                            "color": "green",
                                            "size": "large"
                                        }
                                    ]
                                },
                                {
                                    "spacing": "medium",
                                    "separator": "true",
                                    "type": "Column",
                                    "items": [
                                        {
                                            "type": "TextBlock",
                                            "horizontalAlignment": "left",
                                            "text": "Catches",
                                            "color": "blue",
                                            "size": "small"
                                        },
                                        {
                                            "spacing": "none",
                                            "horizontalAlignment": "left",
                                            "type": "TextBlock",
                                            "text": "{panel:[monCatches]}",
                                            "weight": "bold",
                                            "color": "green",
                                            "size": "large"
                                        }
                                    ]
                                },
                                {
                                    "spacing": "medium",
                                    "separator": "true",
                                    "type": "Column",
                                    "items": [
                                        {
                                            "type": "TextBlock",
                                            "horizontalAlignment": "left",
                                            "text": "Scheduled",
                                            "color": "blue",
                                            "size": "small"
                                        },
                                        {
                                            "spacing": "none",
                                            "horizontalAlignment": "left",
                                            "type": "TextBlock",
                                            "text": "{panel:[monScheduled]}",
                                            "weight": "bold",
                                            "color": "green",
                                            "size": "large"
                                        }
                                    ]
                                },
                                {
                                    "spacing": "medium",
                                    "separator": "true",
                                    "type": "Column",
                                    "items": [
                                        {
                                            "horizontalAlignment": "left",
                                            "type": "TextBlock",
                                            "text": "Total For Kill ",
                                            "color": "blue",
                                            "size": "small"
                                        },
                                        {
                                            "spacing": "none",
                                            "horizontalAlignment": "left",
                                            "type": "TextBlock",
                                            "text": "{panel:[monTotKill]}",
                                            "weight": "bold",
                                            "color": "green",
                                            "size": "large"
                                        }
                                    ]
                                },
                                {
                                    "spacing": "medium",
                                    "separator": "true",
                                    "type": "Column",
                                    "items": [
                                        {
                                            "type": "TextBlock",
                                            "horizontalAlignment": "left",
                                            "text": "Est Kill",
                                            "color": "blue",
                                            "size": "small"
                                        },
                                        {
                                            "spacing": "none",
                                            "horizontalAlignment": "left",
                                            "type": "TextBlock",
                                            "text": "{panel:[monEstKill]}",
                                            "weight": "bold",
                                            "color": "green",
                                            "size": "large"
                                        }
                                    ]
                                }
                            ]
                        },
                        {
                            "type": "ActionSet",
                            "actions": [
                                {
                                    "type": "Action.ShowCard",
                                    "title": "Update",
                                    "card": {
                                        "showCarousel": true,
                                        "body": [
                                            {
                                                "type": "TextBlock",
                                                "size": "extraLarge",
                                                "weight": "bold",
                                                "horizontalAlignment": "center",
                                                "spacing": "large",
                                                "color": "attention",
                                                "text": "Monday Parameters"
                                            },
                                            {
                                                "type": "ColumnSet",
                                                "spacing": "default",
                                                "style": "",
                                                "columns": [
                                                    {
                                                        "type": "Column",
                                                        "spacing": "default",
                                                        "style": {
                                                            "margin-left": "10px"
                                                        },
                                                        "items": [
                                                            {
                                                                "type": "TextBlock",
                                                                "size": "medium",
                                                                "weight": "light",
                                                                "horizontalAlignment": "center",
                                                                "spacing": "small",
                                                                "color": "attention",
                                                                "text": "AM Standing"
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        "type": "Column",
                                                        "spacing": "default",
                                                        "style": {
                                                            "margin-right": "250px",
                                                            "width": "10px"
                                                        },
                                                        "items": [
                                                            {
                                                                "type": "Input.Number",
                                                                "id": "selectVal1",
                                                                "class": "custom-select",
                                                                "displayType": "compact",
                                                                "value": "{value:[swap_lever1]}"
                                                            }
                                                        ]
                                                    }
                                                ]
                                            },
                                            {
                                                "type": "ColumnSet",
                                                "spacing": "default",
                                                "style": "",
                                                "columns": [
                                                    {
                                                        "type": "Column",
                                                        "spacing": "default",
                                                        "style": {
                                                            "margin-left": "10px"
                                                        },
                                                        "items": [
                                                            {
                                                                "type": "TextBlock",
                                                                "size": "medium",
                                                                "weight": "light",
                                                                "horizontalAlignment": "center",
                                                                "spacing": "small",
                                                                "color": "attention",
                                                                "text": "Catches"
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        "type": "Column",
                                                        "spacing": "default",
                                                        "style": {
                                                            "margin-right": "250px",
                                                            "width": "10px"
                                                        },
                                                        "items": [
                                                            {
                                                                "type": "Input.Number",
                                                                "id": "selectVal2",
                                                                "class": "custom-select",
                                                                "displayType": "compact",
                                                                "value": "{value:[swap_lever2]}"
                                                            }
                                                        ]
                                                    }
                                                ]
                                            },
                                            {
                                                "type": "ColumnSet",
                                                "spacing": "default",
                                                "style": "",
                                                "columns": [
                                                    {
                                                        "type": "Column",
                                                        "spacing": "default",
                                                        "style": {
                                                            "margin-left": "10px"
                                                        },
                                                        "items": [
                                                            {
                                                                "type": "TextBlock",
                                                                "size": "medium",
                                                                "weight": "light",
                                                                "horizontalAlignment": "center",
                                                                "spacing": "small",
                                                                "color": "attention",
                                                                "text": "Scheduled"
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        "type": "Column",
                                                        "spacing": "default",
                                                        "style": {
                                                            "margin-right": "250px",
                                                            "width": "10px"
                                                        },
                                                        "items": [
                                                            {
                                                                "type": "Input.Number",
                                                                "id": "selectVal3",
                                                                "class": "custom-select",
                                                                "displayType": "compact",
                                                                "value": "{value:[swap_lever3]}"
                                                            }
                                                        ]
                                                    }
                                                ]
                                            },
                                            {
                                                "type": "ColumnSet",
                                                "spacing": "default",
                                                "style": "",
                                                "columns": [
                                                    {
                                                        "type": "Column",
                                                        "spacing": "small",
                                                        "style": {
                                                            "margin-left": "10px"
                                                        },
                                                        "items": [
                                                            {
                                                                "type": "TextBlock",
                                                                "size": "medium",
                                                                "weight": "light",
                                                                "horizontalAlignment": "center",
                                                                "spacing": "small",
                                                                "color": "attention",
                                                                "text": "Est Kill"
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        "type": "Column",
                                                        "spacing": "small",
                                                        "style": {
                                                            "margin-right": "250px",
                                                            "width": "10px"
                                                        },
                                                        "items": [
                                                            {
                                                                "type": "Input.Number",
                                                                "id": "selectVal4",
                                                                "class": "custom-select",
                                                                "displayType": "compact",
                                                                "value": "{value:[swap_lever4]}"
                                                            }
                                                        ]
                                                    }
                                                ]
                                            }
                                        ],
                                        "actions": [
                                            {
                                                "type": "Parameters",
                                                "title": "Apply",
                                                "data": {
                                                    "paramsToModify": 4
                                                }
                                            }
                                        ]
                                    }
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

 

Action:

 

//initialize variables
var swapParam = [];

//create an array of swap_levers
for (d = 0; d < payload.data.paramsToModify; d++) {
    swapParam[d] = "swap_lever" + (d + 1);
}

//loop through each of the specified widgets
payload.widget.dashboard.widgets.$$widgets
    //.filter(i => i.oid != payload.widget.oid)
    .forEach(function (widget) {

        //loop through each panel in the widget
        //exclude the filter panel (last panel)
        for (p = 0; p < widget.metadata.panels.length - 1; p++) {

            //loop through each item in the panel
            for (i = 0; i < widget.metadata.panels[p].items.length; i++) {

                //check if the panel item contains context (i.e. a formula)
                if (widget.metadata.panels[p].items[i].jaql.context != undefined) {
                    var queryContext = widget.metadata.panels[p].items[i].jaql.context;

                    //loop through each context in the item
                    for (let [k, v] of Object.entries(queryContext)) {

                        //loop through each swap_lever
                        for (s = 0; s < swapParam.length; s++) {

                            //check if the formula contains the swap_lever
                            if (v.title == swapParam[s]) {
                                var val = 'selectVal' + (s + 1);

                                //update the formula with the swap_lever value that the user entered
                                v.formula = payload.data[val];
                            }
                        }
                    }
                }
            }
        }

        //apply and save changes to the widget
        widget.changesMade('plugin-BloX', ['metadata'])

        //refresh the widget
        widget.refresh();
    })

 

 

2 REPLIES 2

Mmckinst
7 - Data Storage
7 - Data Storage

@sis_support Any chance I could get some help with this one?

rapidbisupport
11 - Data Pipeline
11 - Data Pipeline

Hi @Mmckinst ,

Without being able to set up a test env. it's difficult to understand what's happening here.

I did attempt to recreate this in a BloX control, and it seemed like I could only return payload.widget.dashboard outside of the card.

Replacing this with 'prism.activeDashboard' seemed to remove the error from my side, but I couldn't see the intended behviour.

I'd be happy to provide another set of eyes if you'd like to show me what's going on - we could jump on a teams/zoom call/etc. - send me an email if you'd like to do this.

Let me know how you go?

Thanks,

Daniel

RAPID BI

[email protected]

RAPID BI - Sisense Professional Services | Implementations | Custom Add-ons