Good day, all.
I am requesting some information from an API that first I must request an initial set of record IDs that I then must request further details on that specific record. I have this setup at the moment with a single button click and everything works as expected. The problem is that if I want to run this as a single-click function I need to nest procedures and attempts to refactor similar code-blocks that could be used elsewhere doesn’t seem to parse correctly. I think this is because of the order of parsing operations and the scope when the callback is assigned to the ‘oncompletion’ attribute.
This is an overly-simplistic pseudocode example.
\procedure this-will-never-execute()
<$action-setfield .... />
\end this-will-never-execute
\procedure get-api-ids()
\procedure refactor-me()
<$action-setfield .... />
\end refactor-me
\procedure my-callback()
<<refactor-me>>
<<this-will-never-execute>>
\procedure my-callback
<$action-sendmessage
$message="tm-http-request"
....
oncompletion=<<my-callback>> />
\end get-apt-ids
\procedure get-api-details()
\procedure refactor-me()
<$action-setfield .... />
\end refactor-me
\procedure my-callback()
<<refactor-me>>
<<this-will-never-execute>>
\procedure my-callback
<$action-sendmessage
$message="tm-http-request"
....
oncompletion=<<my-callback>> />
\end get-api-details
<$button actions=<<get-api-ids>> />Get IDs</$button>
<$button actions=<<get-api-details>> />Get Details</$button>
I do not seem able to pull the refactor-me procedure from outside the get-api-ids and get-api-details procedure scopes and avoid redundant code. Any attempt with transclusion shorthands or the widget just result in it being interpreted as plan text and never executing.
Is this something that can be done? Is there a technique of chaining these procedures on callbacks together or some other technique that I am overlooking?
Thanks for you help!