How to store removed value from DropdownTag
Application Type
Reactive
Service Studio Version
11.14.15 (Build 60242)

Hi

I have a DropdownTag. It passes the list to OnChanged action. Normal and expected behaviour is that if I click an existing tag in UI it is removed. 

Is there a way to pass that removed value to OnChanged action? 

My intended use for this is that there will be some values that user will not be able to remove. I can achieve that by flag in my entity but before any DB actions I want to inform the user instantly by message that this value will not to be removed. As far as I understand the functionality of DropdownTag, it always allows user to remove tags.

Solution

@Jussi Ahonen this is actually quite possible through JS, I have made it in the OML I'm about to send, can you please take a look at tell me if this was what you were looking for? The way I've done is a screen action will be triggered when you click on the cross (delete button) of a tag, and that action will also receive the Value of the tag clicked (the value, not the label, so this can for example correspond to the Id of your record in your entity and then you can check and add your logic inside that action).

Let me know if this helped,
Paulo

TestingApp.oml

Hey Jussi,

I don't think you can store the removed value, but you can try to compare the list of selected options on your on change action, and see if the user removed any of those ones that you need t keep, and try to select them again. I know it's a workaround and not exactly what you want, but I can only see an option to have some values pre-selected, not one to disable the remove. 

I know there're some forge components that allow you to do that.

Cheers

Hi Laura

That was my intended plan B but I hoped I wouldn't need to come to that :D

I got workaround working. I write it here in case if someone else needs it. I placed my dropdown tags widget in a block:

  1. Create a local variable as type DropdownOptions List (later list A) 
    1. This is the type that the DropDownTags widget passes on
  2. Inside your aggregate's OnAfterFetch action ListAppend All to the List A variable you created in section 1
    1. This list is to be used in section 3. Peek from there if you are uncertain which aggregate is needed
  3. Set this List A variable as SelectedOptions in DropdownTags widget's properties
  4. Inside DropdownTagsOnChanged action 
    1. set the List A created in section 1 same than the input list to this action (List B). 
      1. I.e assign List A = List B
    2. Then loop the list/aggregate (later List C) where you need to check the justification to remove from
    3. ListAny action checks if any value from input list B equals to the value of the looped list
    4. If there is a match, then loop the next
    5. If match isn't found i.e the loop is handling the newly removed value append it back to the list B
    6. Tell the user they can't remove it
  5. Result is that if user tries to remove the tag that is in the List C
    1. They get an error message
    2. Newly removed value is added back to List A immediately
    3. Tag comes instantly back so the user won't even see that it was briefly removed
    4. If user removes values that are not in the List C they will be normally removed
Solution

@Jussi Ahonen this is actually quite possible through JS, I have made it in the OML I'm about to send, can you please take a look at tell me if this was what you were looking for? The way I've done is a screen action will be triggered when you click on the cross (delete button) of a tag, and that action will also receive the Value of the tag clicked (the value, not the label, so this can for example correspond to the Id of your record in your entity and then you can check and add your logic inside that action).

Let me know if this helped,
Paulo

TestingApp.oml

Hi Paulo

I have no doubts that this could be achieved using JS, only that my JS skills equal to NULL :D 

TestTable is empty so I can't test your solution

Just drag the entity to the UI flow to create two fast  master + detail screens and create a few fast records on your personal environment DB if you want to check! :D

Hope this helps even if you have found a workaround. Also, thanks for sharing the workaround!

Cheers,

Paulo

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