Solved

Indicium OData insert a new record with read only field

  • 9 July 2020
  • 1 reply
  • 108 views

Userlevel 5
Badge +15

I'm trying to insert a record via the Indicium Universal OData API. I'm getting stuck on a read only field. Consider the following data model as example:

I have the tables project and project_vrs (having a reference between them). Please note that ‘project_id’ is read-only in the table project_vrs, and there is no identity used.

If you generate the model you'll see the following screen:

The user can open/add a ‘Project’ and via the details he can access ‘project_vrs’. It also allows him to add a project_vrs.

My question is, how can I reproduce the Windows GUI behaviour via the OData API?

Doing a POST call via Postman inserts the project:

 

The project_id ‘TEST’ is created. When I try to add project_vrs I get an http 403 error:

The Indicium log shows the following interesting line:

dbug: Indicium.Controllers.TableController[0]
Cannot change the value of the property 'project_id' of 'project_vrs'.The application model prohibits editing this property.

This is probably caused by having the project_id set as read only. But without changing the model, how am I able to reproduce the ‘gui’ behaviour? I did take a look at resource staging, and tried, but got a similar debug message when calling a patch on project_id.

icon

Best answer by Vincent Doppenberg 9 July 2020, 10:56

View original

1 reply

Userlevel 6
Badge +4

Hello René,

The feature that causes project_id to have a value in a new project_vrs record is called context propagation. Since project_vrs is a child of project and the reference between them is on the column project_id, this column is considered a context filter for project_vrs. When adding a new record to a detail subject, the values of all context filters are propagated from the master record to the detail record.

When you add a record to project_vrs in the Windows GUI, it knows that you’re adding it in the context of a certain project. Indicium also requires this information in order for it to be able to perform context propagation. That's why in Indicium, context propagation works by means of the URL.

This would be the way to achieve what you're trying to do:

POST
/project(‘TEST’)/detail_ref_project_project_vrs

{
“project_vrs_id”: “1.00”
}

In general, the format of the URL is this:

/master(key)/detail_ref_id

Where the blue parts are dynamic.

I hope this helps.

Reply