The problem I have is that a dmx-api-datasource is processing twice. It is a simple API Data Source linking to a PHP file in the same directory. It simply creates a PDF file as shown in the last screenshot. The funny thing is that both PDFs are exactly the same apart from the first one if missing part of the filename which is returned from the first SC.
The two dmx-serverconnects and the first of the dmx-api-datasource process together. Then, when they have completed the dmx-api-datasource processes again but this time with the result of
Can anyone give me a clue as to why ‘pdf_generate.php’ might be running twice?
This has been happening for quite some time and so is not related to version changes.
Current set-up : SPA Pages, Windows 10, MySQL, PHP
EDIT:
I don’t know why this might help, but could it be something to do with “index”?
Is “index” a reserved word?
In my case, Index is the index registration number of a car and not the $index of the returned query.
Sorry but it is not really clear what are you trying to achieve and what is wrong on the page.
Can you explain what’s your idea and what needs to happen on your page and in what order?
The first time “pdf_generate.php” runs it is missing the value of “index” in the URL from the first SC but it still creates a PDF and saves it to the directory
Neil, all I am asking is - what do you expect to happen / what are you trying to achieve exactly?
Just a simple answer like - “I need this to run first, then that runs, then this and that needs to happen…”
That is what i am trying to understand with my last few posts - is there a relation between these server actions and the pdf generation?
Should one wait for the others? What is the relation?
Please just explain what needs to happen in what order and what are the relations between these steps …
Server Action “sa_create_PDF_from_job_id.php” is a single query which retrieves the data for a single job.
Server Action “sa_create_PDF_imgs.php” is a multiple query which retrieves all the image data for the same job (link URLs etc).
These need to complete before the API call.
This is pretty basic stuff, thought you already knew about dynamic events.
So only the first server action runs on page load, then it triggers the second server action on success and the second server actions runs the API call on success.
Thanks Teodor, I don’t know if it’s my age, stupidity or what but sometimes the most simple of tasks become clouded and I need guidance. You’re right, I should have known this but it just didn’t click. Now you have shown me the light, it’s like magic and all becomes clear again. Sorry for wasting your time.
Maybe it’s good to explain how the server actions work, probably it’s not well explained in our docs.
If you have 3 server actions (or API calls) set on page load - they load asynchronously. They don’t wait for the previous one to finish running in order to run. So they will load at the same time and if any of them needs data from the others it may not receive the data, as the other server actions may not yet be loaded.
So if you have a server action which needs data from other server actions you have two options:
Use flows and add server actions there (do not use run in this case) they will be executed one after another (synchronously)
Disable auto load for all server actions except for the first one. Then use the success dynamic event to run them in the order you need. I.e. the first one loads the second one on success etc.