Hye everyone, I am doing a praise app. And I wanted to ask if fk and pk can be the same. Since I try to tally the value but the fk keep on appear value "1" instead of the value in pk table. I want to tally them because I want to take the data from parent table to send email to manager email that is in parent table
It is not having error the reason you are getting error was because of the code which is overrides.
See when I save it every record has different category based on their IDs
Let me put those to a separate oap file then you will see. -
To open the OAP file if you found any trouble visit this link below -
https://www.outsystems.com/forums/discussion/82761/aggregates-101-exercise-oap-cant-be-found/
https://www.outsystems.com/forums/discussion/87615/cant-find-the-patient-portal-oap-file/
ThanksTousif Khan
HI @Raihan Afiqah Latip ,While updating the foreign key in the table, did you pass the proper value?Please check the assignments in your create/update logic.If you referring Table A to Table B then the the FK must be the same as PK to build a relation between them.Regards,Anubhav
This is my file, I am pretty sure my logic is fine. Can you check my file why the foreign key is not updated same as primary key
I checked your implementation, you buind your dropdown with Aggregate and storing the selected value in the same Aggregate, instead of this you can create a new local variable of the category identifier and assign it in the variable of the dropdown.And while passing to your action " CreatePraiseWrapper" use the same local variable.
Note: In your dropdown aggregate, you don't have any data, so it doesn't have any available PK to save as FK. This is why you are getting 1 repeatedly.
Regards,
Anubhav
I have created the local variable but somehow it does not work. Can you review this again because I really want this one to work
Hi, You don't need so many variables to save Praise, put it in a form and get GetPraiseById save this record and see my changes below
Hello,
First I would like to explain you From Master table You can take the Primary key for the elected value and you can assign to the Table where you need to create any relationship.
If you are creating any relationship it can be 1-1 , 1- many or many to many, you will define a foreign key in the respective table, it can be same on multiple records or can be different, it is totally depends on the business requirements.
The other this as suggested to you above you can follow the approach.
I suggest you to please go through the concept and understand the Guided path course from training section to have a clarity on basics, it would really help.
I have go through the concept and go through the exercise. Even the exercise given the fk is not sync with the pk value
The primary key Of table A will be same in Table B as a Foreign key.
It can be same on multiple records of table B or it can be different depends on the value you choose from table A.
Is that what you want?
Thanks & Regards
Tousif Khan
Hello
I just made a change to your oml hope it will resolve for you now
There is no need to explicitly save the value of the fk in your praise table-
You have already given the foreign key, you can easily fetch the data by adding a join no need for extra attribute for category name.
Add a join on the aggregate where you want to fetch the data and just take value from category aggregate
Also I see there are lot of things that are not right like what is the use to pass all the values through input parameters when you are already saving it to your database.
The other thing, why we need to create multiple screen when we can just do the same on a single screen and by passing the category Id we can fetch the data from the database table and assign it, also we can save the heading to db or we can simple put them Ito if else.
Or the best way we can create the same on a single block and manipulate it basis on the category we selected and saved.
this way it would be dynamic and we don't have to hardcode each and everything
For now I have just made some changes to your code to fix this as a quick solution, but for the wider scope you must follow the above
I hope this will help you solve the issue.
Also the reason the Id getting saved into your table is wrong because simply you are not assigning it and by default it is taking the current one -
Why is it too many error..
Thank you so much for your help. I really appreciate it. May I know what make it work specifically? Is it because you group the local variable?
You are welcome :) , Yes to have a clean code and you can easily assign it where ever you like, this is the basic case, when we have large applications and have buch of logics it is a good practice to group things into variables and structures
Thanks
I am basically practicing what you did for category for "recipient" but it did not work. Can you walk me through the other step other than adding the input and output parameter. Btw I want to link the recipient so that I can get the manager info from the recipient table
When Creating a Record in a Praise assign the Recipient Id,
What you can do here If the Recipient Entity has record in it , either you can show the records or add them. via dropdown.
Since this is discussion is getting somewhere eles, I suggest you to open a new case and add the sample OAP file. So it will get other community replies as well, mean while I'll look into it.