Run a SC based on output of another SC

hi,
feel this is going to be a silly question but not being a real developer but a copy paste warrior I have to ask :wink:

I have a pretty complex page that runs quite a few SC queries, many are based on another action, i.e an update/delete action so only triggers the SC when the user does some action on the page.

but, is it possible to have a SC run on page load BUT only when another SC returns a certain value/

i.e I have a page that has a clients booking summary, the booking will get marked as “complete”, so when the page loads we know the job is complete, if that is the case I need to run a SC to see if they have left a review for the booking and if not present them with a box to leave a review.

I know about doing conditional rows/columns so can show my review row when “complete” is true, but, I only want the review SC to run when this panel shows

hope that all makes sense. just trying to minimise the number of connections on page load

thanks
Darren

I guess you could run a ternary on a success event of the first SC and check condition there. Or if it is a complex one you could run a flow on success event and check conditions there.

1 Like

Depending on how many options you want to cater for, if just a couple the ternary option is a great one. Alternatively, if you have a lot, you could create a little JS function that gets called on success via a flow. If the name of the one you want to call is a value from the query, the SC connection could be dynamic - use dmx.parse() to call it within the function.

e.g.

function runsc(v) {
    dmx.parse('SC_'+v+'.load({},true)');
}

in the example it might be calling SC_memberdetails based on the query returning ‘memberdetails’. The true parameter forces reload of the data if you use caching.