Survey banner
The Dataiku Community is moving to a new home! New posts are now disabled and the community will shortly be in temporary read only mode: LEARN MORE

How to send a parameter from AngularJS to my file?

Level 1
How to send a parameter from AngularJS to my file?

I have the following plugin implementation:

A dataset is fed to the plugin --> the file extracts the column names --> Using AngularJS,  callPythonDo() and the proper HTML, the custom form shows the names of the columns to the user --> the user selects a column-name. So far so good. How do I "send" the selected parameter ($scope.column_name) back to the file so that I perform a filtering process (get the elements of that column) in the back-end and I send my result again back to my custom form?

Operating system used: Windows

0 Kudos
3 Replies

Hi, we do have a good example of how to fetch data for custom forms using the "callPythonDo" function in our documentation here

In addition to that, you can pass some data directly with the call of the "callPythonDo({mydata})", which then will be available in the payload of the "do" function.


$scope.callPythonDo({mydata}).then(function(data) {



Hope this helps.




Level 1

No that didn't work. My code looks like this:

// AngularJS:

// Step1: Loading a dictionary from PythonDo
// Initial screen where the user can select values from a dropdown menu
$scope.init = function () {
            $scope.callPythonDo({}).then(function (data) {
                $scope.choices = data['choices'];

// Step2: The user clicks on "Proceed to step 2" button and wants the selected values to be sent back to PythonDo
        $scope.proceedToStep2 = function() {
            $scope.callPythonDo({$scope.selectedValue}).then(function (data) {
                console.log("This is the return of PythonDo: ", data)
# PythonDo
def do(payload, config, plugin_config, inputs):
    if payload:
        # This should take the selected value (as payload) when the user clicks on "Step2" and return this message.
        return "This is the selected value returned from pythonDo"
        # Function that creates all available user options for Step 1
        user_options = create_user_options()
        return {'choices': user_options}

 I think that code should console log: "This is the return of PythonDo: This is the selected value returned from pythonDo" but it does not. 

0 Kudos

Hi, your code doesn't look right. Please refer to the quick test from my lab below:


var app = angular.module('customModel.recipe', []);

app.controller('MyCustomFormController', function($scope) {
    var updateChoices = function() {
        var filterColumnConfig = $scope.config
        var filterColumnConfig = $scope.config

        $scope.callPythonDo({filterColumnConfig}).then(function(data) {
            // success
            $scope.choices = data.choices;
        }, function(data) {
            // failure
            $scope.choices = [];
    $scope.$watch('config.filterColumn', updateChoices);

Python do function:

# inputs is the list of input roles (in case of a recipe)
def do(payload, config, plugin_config, inputs):
    return {}

Console output:

{filterColumn: 'asdf'}

Backend logs:

[2023/06/28-16:19:24.573] [KNL-python-single-command-kernel-out-1170] [INFO] [dku.utils]  - ------------payload----------------
[2023/06/28-16:19:24.573] [KNL-python-single-command-kernel-out-1170] [INFO] [dku.utils]  - {'filterColumnConfig': {'filterColumn': 'asdf'}}
[2023/06/28-16:19:24.573] [KNL-python-single-command-kernel-out-1170] [INFO] [dku.utils]  - ----------------------------


I hope the above will be helpful.



0 Kudos