23
Views
4
Comments
Solved
Outsystems Reactive Associate Question.
Question

Hey all.

Consider the following exam question.


'D' is correct!

Why would you need to set the default value of a local variable in an on initialize event???

Can't you just set the variable a default value in the variable properties? 


2023-01-26 16-03-24
Ana Agostinho
Solution

Hello Joseph Robins, 

I hope this message finds you well. 
In resume, this are the most relevant use cases you can implement with The OnInitialize event handler:

  • Assign a variable based on inputs.
  • Assign a variable based on some computation in JavaScript, such as a random number.
  • Redirect the application to another Screen if the user doesn’t have the authorization to see the Screen (only possible if the event handler belongs to a Screen).
  • Assign the parameters of a child Block based on the inputs of the Screen.
  • Access variables of the JavaScript window object.

There are also some notes you should take into account, such as:

  • Keep this event handler action simple and avoid slow actions such as local storage operations, since it may delay the rendering of the Screen or Block.
  • Avoid accessing the data of the Screen or Block since this action runs before the data is fetched.

Anyway, if you need more information regarding events, check the following link:
https://success.outsystems.com/documentation/11/developing_an_application/implement_application_logic/screen_and_block_lifecycle_events/

Best regards, 
Ana Agostinho

2023-04-16 15-25-31
Krishnanand Pathak

Hi @Joseph Robins 


Suppose your are getting some value through input parameter based on that you need to set local variables. Which is not possible through local variables default values(Conditional values).

Regards 

Krishnanand Pathak

UserImage.jpg
Davy Loose

True, but the question should state “Considering  the oninitialise of event of a screen where input parameters are passed in”...

Poor question format if you ask me. 

2023-01-26 16-03-24
Ana Agostinho
Solution

Hello Joseph Robins, 

I hope this message finds you well. 
In resume, this are the most relevant use cases you can implement with The OnInitialize event handler:

  • Assign a variable based on inputs.
  • Assign a variable based on some computation in JavaScript, such as a random number.
  • Redirect the application to another Screen if the user doesn’t have the authorization to see the Screen (only possible if the event handler belongs to a Screen).
  • Assign the parameters of a child Block based on the inputs of the Screen.
  • Access variables of the JavaScript window object.

There are also some notes you should take into account, such as:

  • Keep this event handler action simple and avoid slow actions such as local storage operations, since it may delay the rendering of the Screen or Block.
  • Avoid accessing the data of the Screen or Block since this action runs before the data is fetched.

Anyway, if you need more information regarding events, check the following link:
https://success.outsystems.com/documentation/11/developing_an_application/implement_application_logic/screen_and_block_lifecycle_events/

Best regards, 
Ana Agostinho

2021-09-06 15-09-53
Dorine Boudry
 
MVP

besides the example of it depending on some input,

  • using the 'default' property in design time only works for simple data types, so you'll need to use the OnInitialize for lists, records, structures, entities or any combination thereof
  • if you need to use any kind of calculations (for example you can use CurrDate() in the default property, but not AddDays(CurrDate(),-30)

So i don't really think it is a poor question

Dorine



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