Solved

Difference between "choose" on dropdown and PATCH request on staged resource

  • 5 September 2022
  • 4 replies
  • 65 views

Userlevel 2
Badge +1

When calling a specific task in our Universal web GUI, a dialogue appears containing a form, in which I can change and enter the form values required to execute said task.

This specific task contains a dropdown select-element, as well as some regular text fields and a few check boxes. Below is one such dialogue:

2 checkboxes, an autofilled textfield, a dropdown and another text field

When I change a value, like (un-)checking one of the checkboxes, I can see in the network inspector of my browser a PATCH request is made on the staged resource.

The request body contains only the changed value, and the response returns two booleans indicating whether the layout and/or resource have changed, respectively.

When I select an item in the dropdown however, I can see in the inspector a POST request is made to a “choose” endpoint, also on the staged resource. The response of this request is similar to the PATCH request.

The request does not contain a body, but the URL looks like below;

staged_task(guid_of_resource)/list_reason_id(status=123,reason_id=456)/choose

The value selected in the dropdown is also a parameter to the staged task, and selecting a value seems to trigger the same follow-up requests.

This has left me wondering what the difference is between the two, and if it is required dropdown values are supplied like this to ensure proper functionality of the dialogue. Would it not be possible, or would it break the form, if I supply the selected value from the dropdown through a PATCH request, similar to how the checkbox values are supplied.

 

Should there be any questions, do please ask them in a comment!

Thanks in advance!

icon

Best answer by Vincent Doppenberg 5 September 2022, 17:22

View original

This topic has been closed for comments

4 replies

Userlevel 6
Badge +4

Hello Jeroen,

The PATCH and choose requests are indeed very similar. The only reason for the existence of the choose request is the fact that the client (e.g. the Universal GUI) can't always determine what the value is that should be patched when a user has selected a lookup record. This is due to column authorization. The column in the lookup table which contains the value that should be patched to the task parameter might be unauthorized for that user. The primary key columns, however, are never unauthorized. So the choose requests asks Indicium to patch the task parameter internally, given the lookup record that the user selected (chose ;-)). Indicium knows which task parameter it is (because of /list_reason_id), Indicium knows what the lookup reference looks like and Indicium knows the unique record in the lookup table (status=123, reason_id=456). Given this information, Indicium can always determine which value is supposed to be patched to the task resource.

So in short, there is no difference between PATCH and choose if the user has access to the referenced columns in the lookup table (or if you simply know beforehand which value you are going to patch). However since this is not always the case, the Universal GUI will always use the choose method for lookups.

I hope this explains the differences.

Userlevel 6
Badge +4

To add to my answer, both PATCH and choose guarantee that the value is within the authorized lookup set of that user. So if you know a PATCH value for a lookup column that would be outside of the locked/hidden lookup prefilters of that user, then Indicium will reject your PATCH request with a 403 Forbidden response.

Userlevel 2
Badge +1

Hi Vincent,

 

Thank you for the thorough explanation!

Just to confirm, by "knowing beforehand which value you are going to patch”, do you mean already knowing I'm supplying value 556 for reason_id, as opposed to looking it up in a lookup table first?

 

Thanks again!

Userlevel 6
Badge +4

Yes, exactly. There’s no need to use choose then.