How To Access Query Parameters When Page Has Just Loaded - AC2 Functions Differently to AC1

My app is often called with a query parameter s.

When the app is loaded, I run a flow, and I test the value of query.s.

In App Connect 1, this value was available in the flow.

Now using App Connect 2 in 6.8.0, it is no longer available... but is definitely available later on in time for example when the user logs in.

Is there something I can do to make the value of a query parameter available in a flow than runs using the dmx-on:ready="" or dmx-on:load="" events of the app?

How do you test that and how did you determine it's not there?

I just tested this and it's available when you call the url with the url param and a value assigned to it - both with auto run flow option and using the onready event:

Thanks for your quick reply @teodor!

So here is my app code:

<body id="index" is="dmx-app" dmx-on:keydown.ctrl.keys.prevent="
((window.value=='app_messages') &amp;&amp; (window_messages_right.value=='message_template'))?f_mailing_message_template.submit():false;
((window.value=='app_activities') &amp;&amp; (window_activities_right.value=='message_template'))?f_message_template.submit():false;
((window.value=='app_activities') &amp;&amp; (window_activities_right.value=='activity_description'))?f_activity_description.submit():false;
((window.value=='app_activities') &amp;&amp; (window_activities_right.value=='activity_dates') &amp;&amp; (window_dates.value=='main'))?f_activity_dates_main.submit():false;
((window.value=='app_activities') &amp;&amp; (window_activities_right.value=='activity_dates') &amp;&amp; (window_dates.value=='advanced'))?f_activity_dates_advanced.submit():false;
((window.value=='app_activities') &amp;&amp; (window_activities_right.value=='activity_titles'))?f_activity_titles.submit():false;
((window.value=='app_activities') &amp;&amp; (window_activities_right.value=='activity_settings') &amp;&amp; (window_activity_settings.value=='main'))?f_activity_settings_main.submit():false;
((window.value=='app_activities') &amp;&amp; (window_activities_right.value=='activity_settings') &amp;&amp; (window_activity_settings.value=='advanced'))?f_activity_settings_advanced.submit():false
" dmx-on:ready="flow_page_loaded.run()">

It happens the same for dmx-on:ready or dmx-on:load.

Here is the flow it runs:

<script is="dmx-flow" id="flow_page_loaded" type="text/dmx-flow">[
  {
    bootbox.alert: {title: "page_loaded", message: "query.s: {{query.s}}"}
  },
  {
    run: {
      outputType: "text",
      action: "{{browser_is_safari.value==1?m_safari.show():false}}"
    }
  },
  {
    run: {outputType: "text", action: "{{banana.setValue('YES!')}}"}
  },
  {
    condition: {
      outputType: "boolean",
      if: "{{query.s.contains('x')}}",
      then: {
        steps: {
          run: {
            outputType: "text",
            action: "{{xero_get_token_from_code.load({csrf_token:csrf_token.value})}}"
          }
        }
      }
    }
  }
]</script>

The bootbox shows no value for query.s in my 6.8.0 app, but does in my 3.9.7 app.

I have the same bootbox in my post login flow and it shows the value of query.s correctly...

Copied your code and tested it:

the bootbox alert shows everything fine.

That's strange then!

Are you using php or node?

It's a PHP page. Maybe check for any errors in the console as well.

Well I do have these errors... I have no idea where they are coming from... if you have any thoughts that would be useful anyhow!

Please provide a link where we can check this. I see some huge html file ... 30k lines. It could be literally anything.

Thanks @Teodor ! You can see it when the page loads, before loggingi in...

https://dev.workshop-angel.com/?s=login

On this page i see Bootstrap 4 and the bootbox components for Bootstrap 4. The bootbox modal does not load for me.

I also see the errors come from some custom js functions you are using on the page such as:

<script>
    document.addEventListener('DOMContentLoaded', function() {
      									const iframe = document.getElementById('if_view_message_template');
      									iframe.addEventListener('load', function() {
          									const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
          									iframe.style.height = iframeDocument.documentElement.scrollHeight + 'px';
      									});
    							 });
</script>
<script>
    document.addEventListener('DOMContentLoaded', function() {
      									const iframe = document.getElementById('if_message_template');
      									iframe.addEventListener('load', function() {
          									const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
          									iframe.style.height = iframeDocument.documentElement.scrollHeight + 'px';
      									});
    							 });
</script>
1 Like

Also, I have just uploaded the version with the bootbox dialogs showing the parameter values to the link below for you to see that happening...

(query.s has the value of 'login')

You can login with the contacts1000@workshop-angel.com account that I DM'd you a password for last week!

https://new.workshop-angel.com/?s=login

The link in the post above has the bootboxes... I just uploaded it!

The previous link was just to see the console errors...

Thanks @teodor, I've fixed those now... much appreciated! :star2:

Query issue remains...

The query parameters data is set on the app instance before the ready event, so it should be available on the ready event, BUT on your page you have a query manager called query and this is what is probably causing this issue on the page.
Try renaming the query manager to something different than just query to see if that fixes your issue.

1 Like