Custom widgets or exec script based on card info

When viewing a card for a class containing an IP address field, we can use the built-in widget to ping that address. Is there a way to do our own widgets? If not, is there any mechanism that would allow us to execute code (Java, Javascript, shell script, call an url, etc…) based on the info of the current card?

I know you can use Form Triggers with event ‘After insert/edit/clone’ and in trigger you can use javascript + ExtJS library

Yea. I would have prefered a way where I can press a button to execute the action, but probably I’ll have to do it using this mechanism. Maybe I can create a text field, called Action, and the user would edit a card, type for example : “PING” in this field, and I would put code to execute After Edit and execute the action that is in the Action field. It’s really not a clean solution, but I see no other way.

Ok, have you tried Context Menu? I mean ‘Contextual menu’ from part 6.1.8 of Administrator manual.

This looked promising. I tried creating a contextual menu, but I don’t know how to activate it. I don’t know how it should look like. Normally to activate a contextual menu in an application we have to right-click on an object, but when I do in cmdBuild I get a contextual menu from my browser.

I had the same problem) The menu is on the top panel:

Thank you! You got it. I put a small Javascript code to display an alert and it worked. Now do you know how we can get the list of items currently selected in Javascript? Or the current item?

Sadly, here i can’t help you.
But (as with triggers) you can write javascript code that print to console all arguments that are passed to the function that handle your context menu code. You can try to find current selection within its and its descendants.
I hope you understand technically my idea.

I think I do. But for this to work I hope that the info is being passed to the function, and that I don’t have to call a service to get the list of currently selected items. But I’ll do some tests.

Hi! Do you have any progress?

No, I tried many things but no success. I wish Tecnoteca would provide some Javascript examples for Contextual Menus, form triggers and validation rules. It’s not enough to just say “you can put custom Javascript here”.

Ok, create menu:
and use it:

Thanks! It works. I was doing alert() instead of console.log(), and that didn’t output the data, as I suppose it’s expecting a string.

Here’s an example for people interested:

// To output all arguments

// To output the Code attribute of the first selected card