Get a List of Identifiers from the Webblock to the parent screen
Service Studio Version
11.14.14 (Build 59923)

In the parent screen I have a list widget and inside the list widget I have a webblock, creating a list of webblocks.
Inside the webblock i can select a checkbox and everytime i do that row "IsSelected" attribute changes to "True" and the Id of that row is appended to a variable (inside the webblock) with the data type as "List of Identifiers".
Now what i can't do, is access to that List of Identifiers on the Parent Screen.
Any idea that can help please?
(I'm on Reactive btw)

Thank you

Solution

@Diogo E Filipe
After looking at your code, I think I understand better what you want. basically you want to have the list of answers identifiers in the parent screen right? Well if that's the case, I suggest you to NOT be listAppending answers to that List in the QuestionAndAnswers block onchange action. Instead,you can do the following:

In the parent screen, create a list to store the given answers, this can be a list that contains an answerId and questionId (for that you can create a structure with those two attributes):

This will be the local variable list where you will save your answers.


After that, in the OnChange action of the checkbox of an answer, you trigger an event, where you will pass the AnswerId that was clicked as well as the QuestionId, as you can see in the image below:


After this, you will need to define the Handler action that will be triggered when the event brings the info to the parent screen.Let's call this action RegisterAnswerGiven

In that handler action, is where you will fill in the newly created list variable, and so the handler action will look something like so:
The reason why you don't simply append directly the Id that comes from the event is because there can already be an answer given for that question in the list. Because of that, you can filter the list for any answer given to that Question, remove that answer first from the list, and then yes, you append the new answer that came from the event.

This should work and your end result will be having all the answers stored in this list!

Hope this helps.
Cheers,
Paulo

Hi @Diogo E Filipe  can you please attach the OML that isn't working?

But if your question is on how to have access in the parent screen to data/variables that you have in your web block, you can trigger an Event to send the data you want, from your block to the parent screen.

You have full outsystems documentation regarding that in this link:
https://success.outsystems.com/Documentation/11/Developing_an_Application/Design_UI/Reuse_UI/Use_Events_to_Propagate_Changes_From_a_Block_to_the_Parent

Hope it helps!
Cheers,
Paulo

Hi @Paulo Ritto, thank you for the answer.
It's not that isn't working properly, it's more that i'm still a noob in this ahah.
Here's the oml. I tried the events but the event has an input parameter right...isn't that if i want to send data from parent to block?

EDIT: After reviewing the link you sent me, i still find myself with the problem...i can not add a button to that block or in the parent page i'd have a bottun per block, since it's on a list. I can't connect the block event to the checkbox either or i would have no control over the logic and a user could select all answers by clicking all checkboxes.

I'm really...blocked xD

Exam.oml
Solution

@Diogo E Filipe
After looking at your code, I think I understand better what you want. basically you want to have the list of answers identifiers in the parent screen right? Well if that's the case, I suggest you to NOT be listAppending answers to that List in the QuestionAndAnswers block onchange action. Instead,you can do the following:

In the parent screen, create a list to store the given answers, this can be a list that contains an answerId and questionId (for that you can create a structure with those two attributes):

This will be the local variable list where you will save your answers.


After that, in the OnChange action of the checkbox of an answer, you trigger an event, where you will pass the AnswerId that was clicked as well as the QuestionId, as you can see in the image below:


After this, you will need to define the Handler action that will be triggered when the event brings the info to the parent screen.Let's call this action RegisterAnswerGiven

In that handler action, is where you will fill in the newly created list variable, and so the handler action will look something like so:
The reason why you don't simply append directly the Id that comes from the event is because there can already be an answer given for that question in the list. Because of that, you can filter the list for any answer given to that Question, remove that answer first from the list, and then yes, you append the new answer that came from the event.

This should work and your end result will be having all the answers stored in this list!

Hope this helps.
Cheers,
Paulo

@Diogo E Filipe

Let me know if the explanation provided helped you in any way :)

@Paulo Ritto hi, after looking at your logic, I think thats precisely what i need...then with the button Submit i just have to do a forEach cycle with CreateOrUpgradeExam_Question_Answer so i can save the Exam, with the random questionsIds and Chosen Answers.

Thanks a lot for the help :)

I'm just having a little bit of trouble defining the ListIndexOf, you put in the RegisterAnswerGiven condition...ahahah, sorry I'm still very new at this with a month and a half of experience in Outsystems, so i still have to stop and think things through...i still lose a lot of time sometimes with simple problems(well they are simple after i solve them xD)

But again, thanks a lot for the help.
Cheers

listIndexOf is a system action provided to you by the platform, just like the listAppend.
The goal is to find the Index (position in the list) of a specific element that fulfills the condition that you pass.
In this case you want to search for any old answer given to the question you are currently on, so the condition may be something like

QuestionId = ChosenQuestionId

You are basically searching for answers for the same questionId that you passed through the event. And the action will return the index that you will then pass to the ListRemove OR it will return  -1 if there aren't any previous answers to that question (in this case you just append your answer and you don't need to remove anything).

Glad I could help, good luck!

Paulo

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.