Creating a new category with an image
Question
Application Type
Reactive
Service Studio Version
11.50.12 (Build 48992)

I have a form where a can create new categories (for rubricating articles), and now I want to add in the same form an image linked to the new category. But on saving the form I'm getting the error 'Request failed with an error'. I've tried several things but no luck.  In some cases I've managed to create a new category, but the image isn't created. 

I've added several screenshots to explain.

1. The form for creating a new Category

2. The form within Service Studio

3. The OnSaveClick, to first save the Categoryname first (3a) and after that the Category-image (3b)

4. The database tables / entities

Anyone suggestions for solving this issue?


I‘ve managed now to create the correct assignments :) 

To better help you with your question, could you share the .oml file?

As of now, you do not check if your server actions have succeeded to run without errors, therefore the user will always get the "Category is successfully saved" message no matter the outcome.


Hello Jay,

Could you please share your OML to look exactly into your issue? 

However, it looks like you are not passing the CategoryID into the CategoryImage entity correctly. The ID generated into CreateUpdateCategory action need be pass to the CreateUpdateImageCategory action as CategoryID.

Thanks & Kind Regards,

Sachin

Thx voor reply's. I've uploaded OML-file.

Articlessmallv2.oml

Hi Jay,


I looked at your .OML file, a few things I noticed:

1) The check for duplicate category names will not work like you intend it too, as this aggregate will only be filled after called the CreateUpdateCategory action.

2) You are trying to create a category image, however, the server action CreateUpdateCategoryImage is just a loop with itself (never create loops!).

3) You are giving the wrong input for this action, as you should require a CategoryId instead of a CategoryImageId.


If you haven't done so already, I highly recommend doing the complete course on Associate Reactive Development (and creating the IMDB app). This will discuss many of the features you are currently trying to build.

Hi,

I've already done the course, but on this issue it hasn't helped me out. I've now added in the OnSaveClick an Assign between action CreateUpdateCategory and the action CreateUpdateCategoryImage. Here I assigned variables Filename and Filecontent to the desired outcome. And also assigned CategoryId to 'GetCategoryImageById.List.Current.CategoryImage.CategoryId'. 

But the result is that the dbs-fields in the CategoryImage table are filled with the wrong CategoryId (Id 2, organisation). It seems that the Id generated into CreateUpdateCategory action is not correctly passed to the CreateUpdateCategoryImage action.

I'm relatively new to OS...., hope that there could be more explanation on passing variables in screens/actions.

BTW, the check on existing category names was working well.

I‘ve managed now to create the correct assignments :) 

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