Populate elements from API

griffin

Member
Greetings

I am planning to create a new application that records the information of a business including official company records filed with the government agency. The government agency provides an API to access the data. There would be one element that would be the Watch element (not sure if that’s the right terminology) – which then matches to the company.

This is what I want to be able to do:

Import the company data through use of API based on entering Name of Company in one element (the Watch element) that populates through the API match of company name in the official register (by filtered dropdown list of companies) and fetches the data required for the company selected and auto-fills the other elements in the form.

My dilemma:

Companies may have one Director or many – how to create record of each Director depending on the number of Directors imported through API.

For each Director need elements for firstName, middleName, lastName, address1, address2, address3, address4, appointmentDate – which are populated from data fetched from API.

Companies may have one Shareholder or many and are recorded as Allocations on the official register – how to create record of each Shareholder depending on the number of Shareholders imported through API. Shares can also be jointly held by more than 1 person – how to create record of each person associated with each Allocation of shares.

For each Shareholder need elements for firstName, middleName, lastName, address1, address2, address3, address4, numberOfShares, percentageHeld and as some Allocations may have multiple owners there could be more than one firstName, middleName, lastName, address1, address2, address3, address4 for each Allocation of shares – which are populated from the data fetched from API.

The problem I have in the concept is:

How would I create a form that would be populated by the data fetched from the API that can add more than one Director and add more than one Shareholder – and add however many people needed to jointly held Allocations? It’s maybe like a having a Repeating Group which automatically adds records based on the data returned, but I am unsure of how this would be automatically triggered by the API.

Any thoughts/pointers would be appreciated – or is this not possible?

Cheers
Chris
 
It'd be possible, but anything involving adding repeat groups through scripting isn't easy. You'd have to add your own user_ajax.php and a form_X.js, to trigger and AJAX call to the server when the company is selected, do the API call on the server side, return the results as JSON to the JS, and add the repeat groups programatically. Do-able, but not trivial.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top