22
Views
8
Comments
Solved
Store Image in Entity
Question
Application Type
Reactive
Service Studio Version
11.10.7 (Build 37468)

Hello



I am new to Outsystems and am currently working my way through the guided paths. I have now already read some entries about "Image and Entities", but I do not manage to solve my problem.

I have a page with the overview of all tasks:

On the Taks_NewEdit page, I now want to be able to add an image to each task and save it.

I have not managed so far to save the image in the provided entity "TasksImage". Can you tell me what I am doing wrong?



Tasks.oml

Champion
Rank: #264
Solution

Hi Benjamin,


Looking at your action, you didn't save the image to the entity (check screenshot below)

or you can put in the Task_CreateOrUpdate Action

Thank you Toto, it works now.

mvp_badge
MVP
Rank: #2

Hi Benjamin,

I'm not sure I understand where your problem is. In your Save Action, there's no attempt to save the image data, so in which ways did you "not manage"?

Hi Kilian

I rebuilt this this morning and translated it from German to English, thought it might be easier.  I created a new server action and my attempt looked something like this:


And I did not manage to fix the error. I did it the way Toto suggested and it now works. Hope I´m on the right way now.

Greets Benjamin

mvp_badge
MVP
Rank: #2

You need to pass an Entity Record as input to the CreateOrUpdate Entity Action, but you supplied a Task Identifier, so that's indeed not going to work.

Note also that it pays off to have consistent naming of your variables, so something that's a Task Identifier should be named TaskId, not TaskImage.

Champion
Rank: #264
Solution

Hi Benjamin,


Looking at your action, you didn't save the image to the entity (check screenshot below)

or you can put in the Task_CreateOrUpdate Action

Thank you Toto, it works now.

Hi Benjamin,

you have to add TaskImageId to Tasks Entity. I attached Oml .please check.

Hope this works.

Tasks.oml

Hello

I've tried this before as well, but I saw in a course that they use a one to one connection for the images and not a one to many. As I understand it, I need the One To Many connection if I want to attach multiple images to a task, and the One To One connection if I want to attach only one image. Am I correct?

mvp_badge
MVP
Rank: #2

Yes, if you need just a single image, you can use a 1:1 relation. This can be done by:

  • Using an existing Identifier for primary key, or;
  • Adding a foreign key to the parent Entity.

This as opposed to a 1:many relation where you add the parent Id to the child Entity.