Trying to Return a Single Value From an Array Gives An Error

Just remove the step that causes this error and let me check the output of whatever you are using there in this step trying to format it!

So this server action:

Give this XHR:

Antony, I am not sure if you don’t understand what I mean or if there is some other issue.

I really really really need to see what your server action step returns!
Select your server action and let me see the output.

Teodor, I am clearly mis-understanding you here.

You asked for my dev tools - network - xhr output and I've shown you that graphically and in text without any .where assignments enabled.

Here it is with the .where enabled:

{code: 0, file: "C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\formatters\collections.php",…}
code: 0
file: "C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\formatters\collections.php"
line: 35
message: "Undefined index: "
trace: "#0 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\formatters\collections.php(35): exception_error_handler(8, 'Undefined index...', 'C:\\Users\\anton\\...', 35, Array)↵#1 [internal function]: lib\core\formatter_where(Array, NULL, '==', 'stripe_fee_cate...')↵#2 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(396): call_user_func_array('\\lib\\core\\forma...', Array)↵#3 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(354): lib\core\Parser->objectMember(Object(Closure))↵#4 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(296): lib\core\Parser->primary()↵#5 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(273): lib\core\Parser->group()↵#6 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(253): lib\core\Parser->unary()↵#7 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(243): lib\core\Parser->multiplicative()↵#8 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(233): lib\core\Parser->addictive()↵#9 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(223): lib\core\Parser->bitwiseShift()↵#10 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(213): lib\core\Parser->relational()↵#11 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(203): lib\core\Parser->equality()↵#12 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(193): lib\core\Parser->bitwiseAnd()↵#13 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(183): lib\core\Parser->bitwiseXor()↵#14 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(173): lib\core\Parser->bitwiseOr()↵#15 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(161): lib\core\Parser->logicalAnd()↵#16 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(145): lib\core\Parser->logicalOr()↵#17 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(141): lib\core\Parser->conditional()↵#18 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\core\Parser.php(86): lib\core\Parser->expression()↵#19 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\App.php(221): lib\core\Parser->parse('lookups.where(l...', NULL)↵#20 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\App.php(206): lib\App->parseObject('{{lookups.where...', NULL)↵#21 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\modules\core.php(99): lib\App->parseObject(Object(stdClass))↵#22 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\App.php(173): modules\core->setvalue(Object(stdClass), 'test1')↵#23 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\App.php(137): lib\App->execSteps(Object(stdClass))↵#24 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\App.php(107): lib\App->execSteps(Array)↵#25 C:\Users\anton\Dropbox\workshop-angel\dmxConnectLib\lib\App.php(72): lib\App->exec(Object(stdClass))↵#26 C:\Users\anton\Dropbox\workshop-angel\dmxConnect\api\subscriber_user_settings\set_session_variables.php(8): lib\App->define(Object(stdClass))↵#27 {main}"

What else would you like me to send you?

The lookups.lookup_function is wrong in the expression, the expression should be

{{lookups.where("lookup_function", "==", "stripe_fee_category")}}

@teodor, I didn’t know you could see the output by clicking on the entry in the XHR listing!

Here it was…

@patrick… that is perfect, I have a solution now! :slight_smile:

So this one works:

{{lookups.where("lookup_function", "==", "stripe_fee_category")[0].id}}

and returns me the id value.

However I hope you both know @patrick and @Teodor that the version without the "" around the lookup_function value was created by Wappler, not by me, so is a bug!

Antony,

How did you write those expression in first place?

Why didn’t you just pick them from the UI? It might saved us tons of messages and you hours of struggling … again

But George, I DID pick them from the UI!

I’m sorry to tell you the UI made multiple errors:

  1. Got the ‘0’ in all the wrong places… the UI created these:

lookup

Then it managed to lose all the quotes around the first lookup field in this example which I have just video’d for you and is below.

I’ve done all I can here to show the problems from the start. All I wanted to know was what Patrick was able to tell me in one sentence and I am sure could have told me in response to my post #1.

It has taken about 50 posts to get that answer… so I think this would have been much faster if that knowledge had been available from the beginning! :slight_smile:

Best wishes,
Antony.

PS - it wasn’t helped by the fact that when people said “Show me the output from xxx”, I didn’t know that if you have an api with a 200 status then you can click on that in dev tools and see the output… We don’t always speak the same language!

It does make me sad that your comment seems to say that you trust me... :frowning:

I see, seemed like a simple formula Wappler’s UI should be able to handle.

Was the problem also with experimental features off?

I didn't try it!