Displaying values from variables created in Server Connect

I know there have been related questions before, but I still can’t find a satisfactory solution. This is a general question but here is an example.

During an import process, some records are imported and some are updated. I put the relevant values into session variables like this:

image

I can display these values after the import, but only by echoing the session values with PHP, and using javascript to reload the page. The results is rather clunky: I want to show a notification following a successful import, but this in interrupted by the page refresh (which I would like to avoid anyway).

Is there a way within Wappler to display variables created in Server Connect in situations like this? I suppose I could store the values in a database, but that would be a rather complicated way to achieve what should be a simple task. I would be grateful for any suggestions.

Should that be a session?
You can use SET VALUE step instead, and enable output option. Then on the front end you can use the SET VALUE step value, as any other binding:

{{serverconnectName.data.setValueStepName}}

Thanks Teodor,

I tried using Set Value - where I put the session + 1 step - but the value would not increase. It worked for sessions, so I used them. Perhaps I was using the Set Value in the wrong way. I’ll try again.

What was the result? I've used it many times and it worked really fine.

Great - I’m making progress. I’ve added curly brackets round the variable in server connect and now it’s incrementing. I couldn’t see a way of picking it and I had obviously entered it incorrectly. However, I haven’t managed to get it to display yet.

I’ve added the variable in server connect like this:

image

… and it’s incrementing correctly:

image

The server connect file is linked to a form in app connect. There is no sign of the variable under the form elements:

image

I tried adding an extra server connect file - the same one the form uses - but the variable doesn’t appear there either. I created a variable with the same name in App Connect:

image

… in case that was needed. But still no luck. What should I do to capture that value which is now being created correctly anyway?

The variable won’t appear in the data picker as it’s inside a condition and we don’t know what the condition result it.
You can just use it like: {{serverconnectName.data.setValueStepName}} on your page.

I should have mentioned I had tried a few options like this - obviously not the right one.

The server connect variable is called ‘updatetotal’. I’ve tried this with the following:

Server connect form name:
{{sc_form_import.data.updatetotal}}

Extra server connect (same as used for the form)
{{serverconnect1.data.updatetotal}}

The name of the actual server connect file
{{upload_import.data.updatetotal}}

So it does not return any value on your page? Where have you used this - on the page directly or in some component?
There is no logical reason for it not to show anything on the page if you see it in the output json.

Edit: I now see it is in a repeat, maybe your expression is just wrong.

No, it’s not in any component. I tried these options in new paragraph.

Could the problem be that the variable is in a loop? I can get it to display correctly if I do something like this:

{{sc_frm_import.data.repeat1[3].updatetotal}}

… but of course I’ve having to supply the array index (which I want it to give to me).

You can add a new variable, after the repeat(loop) step, which sums the updatetotal for each of the repeat steps.
Then use the total binding on the page.

1 Like

I tried adding a new variable after the repeat, but am not sure what the expression should be here:

image

The value I need is the final value of updatetotal. I thought just assigning the new variable to this might work, but it doesn’t. I don’t know what I could try here.

Set updatetotal value to 1, then use the sum filter to sum all the values in the updatetotal2.

Thanks - I’m sure I must be very close now. I don’t think I can quite choose what I need using the picker, but I arrived at this:
{{repeat1.updatetotal.sum(repeat1.updatetotal)}}
… which isn’t quite right.

I have to collect a few daughters from a coach now, so shall have to stop for the moment. I really appreciate your help - particularly on a saturday night. I think you’ve earned a few beers by now.

Please use:

{{repeat1.updatetotal.sum(updatetotal)}}

…and …and does it work @TomD, I might run out of bookmarks in this thread in a bit, @Teodor is giving me some handy tips.