Custom module " return key and value "

Hello @patrick,

I created a function like this and I want to use ‘RandomNumber’ as key. However, I cannot get output as key and value, I just see the “value” as in the screenshot and I cannot use this output in another action step. Where is the problem?


  {
    type: 'custom',
    module : 'custom',
    action : 'numbergenerator',
    groupTitle : 'Custom Actions',
    groupIcon : 'fas fa-lg fa-database comp-data',
    title : 'Number Generator',
    icon : 'fas fa-lg fa-table comp-data',
    dataScheme: [
      {name: 'RandomNumber', type: 'number'}
    ],
    dataPickObject: true,
    globalVars: {
      '$_GET' : ['RandomNumber']
    },
    properties : [
      {
        group: 'Properties',
        variables: [
          { 
              name: 'start', 
              optionName: 'start', 
              title: 'Start', 
              type: 'text', 
              required: true, 
              serverDataBindings: true,
              defaultValue: ''
          },
          { 
              name: 'end', 
              optionName: 'end', 
              title: 'End', 
              type: 'text', 
              required: true,
              serverDataBindings: true, 
              defaultValue: ''
          }
        ]
      }
    ]
  }


Function

public function numbergenerator($options, $name)
    {
        option_require($options, 'start');
        option_require($options, 'end');
        $options = $this->app->parseObject($options);
        
        if (isset($options->start) && isset($options->end)) {
            return array('RandomNumber' => rand($options->start, $options->end));
            
        } else {
            Throw new \Exception('There was a problem generating a random number.');
        }
        
    }

Server Action
image

Output
image

Community Page
Last updated: