Help with custom module output

Just when i thought i had got my head around such things.
Written several custom formatters and had no issues
Now on my first tries of custom modules and having on issue regarding returned values
I have a very simple module

exports.tester = function () {
    return 100
}

I have this hjson

{
    type: 'tester',
    module : 'tester'
       action : 'tester',
    groupTitle : 'tester',
   groupIcon : 'fas fa-lg fa-table comp-data',
    title : 'tester',
    icon : 'fas fa-lg fa-table comp-data ',
    dataPickObject: true,
    dataScheme: [
    {name: 'status', type: 'number', optionName: 'status'}
  ],
    properties : [
    {
      group: 'tester',
      variables: [
          
                { name: 'output', optionName: 'output', title: 'Output', type: 'boolean', defaultValue: true }
      ]
    }
  ]
 }

When i output this should i not see ā€œstatusā€ output with a value of 100 i.e.status: 100

Try

return {status: 100}

You return what you have defined in the hjson

Thanks Ken

exports.tester = function () {

    return {status: 100}
}

but still not returning anything

Hate to tag people but can either of you help?
@George @JonL

The problem is default output as TRUE. Set it to false, and it should work with the way Ken has proposed.
And, the NAME input is compulsory. You are missing that.

{ name: 'actionName', optionName: 'name', title: 'Name', type: 'text', required: true, defaultValue: ''},

I have tested this just now, and it works with above changes.

Looks like a bug.

I have used names like ā€œbrian_testerā€ or ā€œstatusesā€ instead of generic words like ā€œtestā€ & ā€œstatusā€, as they might conflict with Wapplerā€™s code - never know.

@sid is right.

The problem is how the SC json file is being built from the hjson.

If you open your SC file in editor you should see something like this:

{
    "name": "tester",
    "module": "tester",
    "action": "tester",
    "options": {},
    "output": true
}

But Iā€™m pretty sure your name will be empty and output wonā€™t be there for the reasons @sid mentions.

If you wanā€™t to change the default value for the output in the UI you need to use initValue

{ name: 'output', optionName: 'output', title: 'Output', initValue: true, defaultValue: false, type: 'boolean'}

Thanks @sid but already tried the default thing , thatā€™s when i noticed the output flag bug I reported, no success

Sorry Sid, not following you on that, can you expand on it as to where i need that?

I have ā€œnameā€ in dataScheme for output

The module has no inputs so I only have ā€œoutputā€ as an item in properties

Where is that line missing?

A variable called name

{ name: ā€˜nameā€™, optionName: ā€˜nameā€™, title: ā€˜Nameā€™, type: ā€˜textā€™, required: true, defaultValue: ā€˜nameā€™, help: ā€˜Help textā€™},

Thanks @JonL yet again but i already changed the default to false without success

Once the hjson is corrected. Remove the step in the workflow and add it again so the SC json file is generated again on save.

@George how about a dropdown somewhere in the UI(Extensions Manager?) to create custom modules/formatters/routes that creates the folders, files and adds some boilerplate to the js and hjson files with commented code like what lines are mandatory, link to docs, etc

2 Likes

Firstly thanks for putting up with my stupidity on this

I amended the hjson to include

I now get an output which is great

image

But i also see "name in the UI which i donā€™t want

How can i hide it?

I think you canā€™t.

You can try to put a default value thereā€¦ and then use a non-existent input as condition for visibility?
See show/hide options.

So i cant have an output unless there is an input?
Seems a bit bizarre for a module?

Thanks again @sid,
Tried all variations of

hide:[], hide:['condition'], and show[] & initDisplay: 'none'

equivalents with no success, guessing they apply specifically to dropdowns.
Need a break from this

Using show: ['actionName'] in option property, I was able to hide the name input by default, but as soon as I enabled output, it would show the name input.

I think it is specifically designed for dropdown, as you say.

And the name input does not show default value either. So I think you will have to live with the name input there.

Huge thanks @sid, i will live with this for the moment and hopefully @George can look at how to/ enabling this facility when he gets time but beta to production has to be the priority at present for the team.
At least i know i am not going completely crazy (just partially)

The name is actually required, and cannot be removed.
When you want to use the custom modulesā€™s output, in steps below, only way to do it is using the name.
So something like name1.status will give you 100. Without the ā€œnameā€ part, you cannot use that stepā€™s outputs.
And this same name is used when actually outputting the value to client side: {"name1":{"status":"100"}}
Hope this makes sense.

Yes, I see that. The output is the value_of_name.dataScheme_name

So if i enter ā€œtestā€ as the value of name then the output is test.status
So i can fix the value with defaultvalue but really want to hide the input box to make that static
Learned a lot more today about custom modules so itā€™s a good day anyway :grinning: