Skip to main content
Solved

Can we make some web endpoints read-only? And can we do the same for individual fields?


Forum|alt.badge.img+4

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") ;
   }
}

 

View original
Did this topic help you find an answer to your question?

2 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

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") ;
   }
}

 


Forum|alt.badge.img+4
  • Author
  • Captain II
  • 508 replies
  • October 5, 2022

I thought that there might be a property that would indicate if the code was running via the Contract API or not.  Thank you!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings