Maximo Open Forum

 View Only

 Query regarding api schema

  • Mobility
Invading Moss's profile image
Invading Moss posted 12-29-2024 06:30

Hi All,

When I hit the API http://localhost:3006/maximo/oslc/jsonschemas/mxapisr I can see the below in the JSON response

  "required": [
    "class",
    "historyflag",
    "status"
  ]

which indicates the required fields.

Question is does this only show the fields which are required at the database level or any field which is made required using other ways (such as application designer, automation script)?

Steven Shull's profile image
Steven Shull

Application designer changes are specific to that application and do not impact object structures. That means we will NOT enforce those during submission. 

Data restrictions (global data restrictions or on the security group) will be enforced through the object structure during submission as long as an application isn't specified. But the jsonschema API won't show that it's required. This is because data restrictions are typically conditional which means you need a specific record to evaluate against to determine if the field is required. For example, if you require the classification when an asset is referenced on the SR. Some SRs you create will have an ASSET and that will be required, others will not.

Similar to above, automation scripts or java classes that alter when a field is required would also normally be enforced during the submission process but would NOT surface in the jsonschema. This is because these are often conditional as well. Something may be required/read-only when the record is approved but may not be required during creation for example. 

There are two concepts in the REST API (edit mode and set value mode) that are not documented and I'm not sure we technically support. But those can work in more specific examples. 

Edit mode is a way to start the creation of the record & then continuously post updates to that in memory record without committing it until you tell the REST API to commit it. The thought process was that similar to the classic UI, as you enter data in a form you may want to validate & identify what is required with the data that has been provided. The problem with this approach is that this record is opened in memory which means that you're dependent on that specific JVM. If that JVM crashes for some reason, gets restarted, you get routed to an alternate JVM, etc. you lose the record. 

Set value mode is a little bit different than above in that we don't keep a record in memory. We send the data through the REST API and then immediately discard it on the server. This avoids some of the issues with edit mode where it's tied to a specific JVM but will cause issues with certain things like autonumbers where that number is consumed every time. 

In both scenarios, if you have a query parameter addschema=1 along with the properties header with the attributes you want to get back, in the response from the server you will get the schema that will be specific to what you've submitted. 

Invading Moss's profile image
Invading Moss

Thanks @Steven Shull

The reason I asked was that I wanted to make certain fields mandatory in SRMOBILE before submission. I could see in the controller.js file that it did check for the required fields in the jsonschema hence the question