If you can wait first for get_activity serverconnect to be executed and have results, you can call this javascript function on the success event of the serverconnect
(in a flow, run javascript)
For anyone doing this with Paypal, once this sdk script has loaded, you have to load your own local script... so I have used an event listener to do that... here is the complete script:
<script>
// loadPaypal function - loads the scripts
function load_paypal() {
const sdk_script = document.createElement('script');
sdk_script.src = `https://www.paypal.com/sdk/js?components=buttons,card-fields&client-id=`+dmx.parse('get_activity.data.pp_client_id');
document.head.appendChild(sdk_script);
const local_script = document.createElement('script');
local_script.src = `paypal.js?x=`+dmx.parse('now_timestamp.value');
// check that they loaded... and call the local one once the SDK has loaded...
sdk_script.addEventListener("load", () => {
console.log("Paypal SDK script loaded");
document.head.appendChild(local_script);
});
local_script.addEventListener("load", () => {
console.log("Paypal LOCAL script loaded")
});
sdk_script.addEventListener("error", (ev) => {
console.log("Error on loading paypal SDK script", ev);
});
local_script.addEventListener("error", (ev) => {
console.log("Error on loading paypal LOCAL script", ev);
});
}
</script>