I will be setting up a nightly PHP script to update the options in our option lists. One of them is a list of employees where the label is an employee name and the key_value is an employee ID number. This list is managed by admin users on our 3rd party system outside of iformbuilder. My goal is to take any changes that were made in our external system and update our iformbuilder lists nightly. In looking through the v6 API docs, I do not see any sort of replace() method that would replace all existing options with a new set. As far as I can tell, the best way is to send a delete request on the option collection without sending any IDs to delete all the options, then send a second request to create the new options.
Why not just update individual options? First of all, it would use more API calls. I would have to use one call to get the existing options. Then I would have to write a bunch of code to compare them all to the current list on our side. There could potentially be new options, deleted options, or existing options updated. So that would be four API calls and a lot more programming to accomplish the same thing. Using one request to delete all options then one request to add new options is much simpler to program is less error-prone. The problem is that it still uses two API calls to accomplish one list update. Updating lists is basically the only thing I will be using the API for, so my 10,000 requests are essentially cut in half. This becomes a problem, for example, if we get up to 170 lists that need to be updated daily (which is possible in the near future). 170 lists * 30 days is 5100 API calls. But if I have to use two calls for each list, it puts me over 10,000 for the month. If I could replace all the options in a list with one API call, that would be much cleaner. Maybe there's already a way to do that and I'm just missing it.
Along the same lines, is it OK to update options by deleting and then re-creating them as long as the key_values are the same? For example, say I have this option: key_value = 1234, label = "First Last". Then I fill out a form and select that option. Then using the API, I delete that option and create a new option with the same key_value but a new label. When I re-open that saved form, will that option still be selected since the key_value is the same? Or is it saved by Option ID and the previous selection would be lost?
Please sign in to leave a comment.