Hi ALl,
Basic query but wanted to send "N" to backend,Can I do directly with using code as extra attribute.
The rightt way to reference values from a static entity in the code is by using the identifier that in OutSystems you can find in Entities.[NameOfEntity].[IdentifierOrRecord].
Example: Entities.YNLocal.No will return "N"
Entities.Cointries.India will return "IN"
and so on.
This way it can even be a autonumber and will always work. Do not hardcode values.
If you don't want to use statics, use texts instead. But be consistent as any error and the code will not make sense.
@Preeti zade : You could change the data type of the Id attribute to Text and set the values explicitly as Y and N. Then you would already have the value you need to send to the backend, without needing an extra Code attribute.
What @Siya suggest is one solution, you can also just use the code to assign like this:So you're using the ID but you get the Code value in this case "Y", "N"
Do you even need a static just for Yes/No? If your goal is to have Y/N, why not use type text and validate the value?
Agree, with @Nuno Reis it's an AO for a Y/N, depending on the context, you might even simplify the handling: for example, using a text type with validation or a reusable function if you want consistency across modules. The important part is recognizing that there are multiple ways to represent Y/N :)
Hi Nuno,
Thank you for the reply but you mean we can directly use text Y or N instead if creating AO
Also for other cases if there are multiple values in static entity so I was checking how we generally pass the value to backend by adding extra attribute?
Adding to what is already mentioned before. This sounds like a boolean, yes or no = true or false. And normally leads to easier code. But I do not know the business case so can not know if this is a good solution for this problem.
Succes, Eric
The difference is that with Boolean Null=False. With a static entity, a text, or anything else, you can have all three: Null, True and False.
A lot of people only realize it later and have to refactor the entities.
This is the nice discussion: can a boolean be NULL?A discussion that is like a boolean: the outcome can be true or false.For me a boolean is like a lightswitch and has just 2 values: on or off.Even if I don't know the status of the lightswitch, the switch is either on or off.And it is up to the developer to decide on the default value ... if optional.The same discussion can be held on the values Yes and No.These can be nice discussions, but not in the context of this forum-item.I think there is enough information for the requestor.
@Eric Slikker Yes it is a nice discussion agree, I remember to read an article about this topic from @Dorine Boudryhttps://itnext.io/implement-a-trilean-in-outsystems-7386ba77bbb1
We can have nice discussions on booleans, trilians and null values, but I have the idea that the question is not answered yet for @Preeti zadeIf you want to solve this using a static entity you don't have to add an extra attribute and don't need to use the integer Id. You can just make the code the identifier and if needed add the meaning in the label.The advantage of using a static entity is that you can use the code in as foreign key in another table to make sure only the values 'Y' or 'N' can be inserted.I hope your question is answered and you have enough information to decide yourself on what you implement.
Hi Eric,
Thank you for thecreply but o m looking like in general if we want to maintain few records with their respective value in code attribute so how to send to backend ,ex entity.country.india for field attribute India, entity.coubtry.brazil
So backend I wanted to send values from static entity
@Preeti zade ,
the reason why people have a hard time answering your exact question, is because it is not clear what you mean with "send it to the backend".
For using statics, whether you are doing stuff on the server side or client side doesn't matter, you code logic against a distinct option everywhere by entities.staticName.valueName, and you pass around a reference between actions and/or store a reference in your database in the form of staticEntity.Identifier.
Using a text id, as suggested above, has the advantage of maybe carrying more meaning when you later look at rows in your database with sql server or such.
Dorine