Help needed: Nested Rest API calls - e.g. Netbox #287
-
What is my Problem? In my case, i'm having one field for a virtual machine and another one which gives me all related contacts for this vm. These contact assignments returns something like:
But in my form i want to extract all contacts with their internal ID Number, which is an custom field in Netbox. Possible Solution? But then i have to do a "like" for each over this array. Make an rest call for each contact assignment and build some kind of array with additional informations. Do someone have an idea how to solve this or solved an slightly different issue? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
in this particular case i would suggest to write your own backend function. AF loads or allows to load a custom functions library exposed as fnc. steal the code from the regular functions. let me know if you need more help. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/ansibleguy76/ansibleforms-docker/blob/main/data/functions/custom.js |
Beta Was this translation helpful? Give feedback.
-
and steal from https://github.com/ansibleguy76/ansibleforms/blob/main/server/src/functions/default.js |
Beta Was this translation helpful? Give feedback.
-
are those custom functions loaded automatically or do we need to allow/enable this? Tried adding my own little function but didn't get it working as it wasn't recognizing the function. Same seems to be for the ones you did include as examples:
TypeError: fn.fnSum is not a function Edit: Looks its because of the breaking changes planned with v6. Was on 5.0.10 but the custom.js I had seems to be converted to the v6 changes with the import instead of require. Edit2: thanks for below answer, seems I did miss the documentation... |
Beta Was this translation helpful? Give feedback.
https://github.com/ansibleguy76/ansibleforms-docker/blob/main/data/functions/custom.js