I’d like to be able to make one of the web endpoints read-only. Is that possible without going through security/roles?
There are some other web endpoints that I would like to make specific fields read-only as well. Is there a way to do that? I could make a non-persisted field that mirrors the value of the field I want to display and expose that in the endpoint. I’m wondering if I’ve overlooked something.
Best answer by Leonardo Justiniano
Hi @ddunn
Certainly using Roles to restrict which entities the API user can write would work. Having specific fields read only requires customizing the screen to prevent setting a value. Something like:
protected void _(Events.RowUpdating<DAC> e) { // If you want to validate only the REST API call if(Base.IsContractBasedAPI && e.Row.Field != e.NewRow.Field) { throw new PXException("ERROR: FIELD READ ONLY") ; } }
Certainly using Roles to restrict which entities the API user can write would work. Having specific fields read only requires customizing the screen to prevent setting a value. Something like:
protected void _(Events.RowUpdating<DAC> e) { // If you want to validate only the REST API call if(Base.IsContractBasedAPI && e.Row.Field != e.NewRow.Field) { throw new PXException("ERROR: FIELD READ ONLY") ; } }