Toggle document favorite yes/no with clicking on an icon in a table
Question
Application Type
Reactive

I've a table with 'documents'. If a specific user is logged in and clicks under the actions on the View or Update icon, the user can in the form with a click on the button 'Add to favorites' mark this document as his/her Favorite. The button toggles then to 'Remove'. In the table the Favorite documents are visible in the column 'Fav show', and user can filter on the Favorites. 

In the column 'Fav toggle', I'm now trying to extend usability. When user clicks on the icon the Favorite status has to be toggled. I've linked the click to the same client-/serveraction as is used in the View and Update form.

See screenshot. 

But when clicking on the icon an error is shown: 'You don't have permissions to view this screen'. I suppose this has to do with the different screens (a list and a form), but I'm not sure. How can I solve this error and make the functionality working? I've added oml.

TestDocumentsv3.oml

mvp_badge
MVP
Solution

Hi Jay,


Indeed it helps.

The exception is raised in the action DocumentFavorite_Remove on the screen Documents, where DocumentFavoriteId input is null, according to your logs and here it is the message:


I did a couple of changes but essentially, when you add a favourite on a given row, you should save the id of the created record in the database on that given row (the List.Current row). And then that is the id you use to remove when you want to remove the favourite.


The OML follows in attachment. I didn't have time to change but it should do the trick.


Kind Regards,
João

TestDocumentsv3.oml

mvp_badge
MVP

Hi Jay,


I noticed on the action CheckRegisteredRole, you're not filling in the UserId. You should fill it with GetUserId().


I am not sure if in the case the input value is not filled if it takes the value of GetUserId() (couldn't find any documentation pointing in that sense).


Kind Regards,
João

Hi João,

Thx for reply. 

Filling in the UserId didn't solve the issue. 

In Servicecenter error log is stated: 'You are missing one or more mandatory inputs'. Details: 

at ssTestDocuments.Actions.ActionDocumentFavorite_Remove(HeContext heContext, Int64 inParamDocumentFavoriteId)

at ssTestDocuments.ScreenServices.TestDocuments_MainFlow_Documents_Controller.<ActionDocumentFavorite_Remove>b__1c(HeContext heContext, String screenName, JObject screenModel, JObject inputParameters, JObject clientVariables)

at OutSystems.RESTService.Controllers.ScreenServicesApiController.endpoint(String input, String endpointName, String apiVersion, EndpointImplementationDelegate implementation)

Until now I didn't see any missing inputs so far, but I could be wrong.... Maybe the details can give a hint?

mvp_badge
MVP
Solution

Hi Jay,


Indeed it helps.

The exception is raised in the action DocumentFavorite_Remove on the screen Documents, where DocumentFavoriteId input is null, according to your logs and here it is the message:


I did a couple of changes but essentially, when you add a favourite on a given row, you should save the id of the created record in the database on that given row (the List.Current row). And then that is the id you use to remove when you want to remove the favourite.


The OML follows in attachment. I didn't have time to change but it should do the trick.


Kind Regards,
João

TestDocumentsv3.oml

Hi João,

Yes, this did the trick! Thx.

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