OS1 Concepts
Custom Code
7min
overview the logistics industry handles a wide range of operations that deals with both the forward and the reverse flow of goods and services it works on a point to point basis with the number of milestones between origin and point of delivery handling the operations and providing relevant information can be unique for each company according to its business logic in such cases, the biggest challenge is to provide a technical layer that could meet each business’s requirements and to provide the scope of enhancing the logic layer in the future custom code support in coreos can help developers implement business specific logic in their applications at different places about custom code custom code helps the developers in defining the rules that govern the complete operational cycle according to their needs, developers can configure custom code in the existing core api services, such as order, dispatch, entity, container, and participant developers can modify the core api services for creation, management, and execution in a self service model here, we will further help you to understand the overall functionality and use of custom code coreos services that support custom code configuration functionality are how to implement custom code in participant services docid\ lqluryx46fdw8tadfonja how to implement custom code in container services docid\ u4csbqobylnrb0sstfwdg how to implement custom code in entity service docid\ gpik qm66eiehzyquagkc how to implement custom code in dispatch service docid\ hcep6go3vs5zsc1yzz9i0 note the link for implementing custom code is provided with each service benefits of using custom code earlier, the developer would build wrappers on coreos services for validation and enrichment this would require the building of a complex validation layer and multiple api calls were required on top of core apis implementing this layer was quite hard for any real time based application as requests would require validations each time they are called in coreos services this issue is resolved with the introduction of custom code it helps in reducing the developer’s efforts to write the complete code structure rather, configure the pre defined custom code for the service it is associated with, and use the pre defined structure code for the rest of the services developers can patch in their custom business logic for corresponding coreos services using custom code libraries available for different services this can be done in a self service manner use cases of custom code different categories where custom code is applicable method validation while updating a value of an attribute, the method/function/code can check for attribute values of objects in the same service or a different service example any billing method changes in the billing service should be notified to the relevant user groups/downstream services state changes a subset of method validation, this point caters to the state change of objects objects have states and they move from one state to another based on predefined rules these rules vary from one business to another and depend on the values of attributes belonging to the same or different coreos service or an external application example for a client state to be changed to ‘active’, there can be checks on the pricing information (from a pricing service) or attributes of the same client object or a third party api service that determines the rules of activation data enrichment populating the values of attributes of an object at any point in the life cycle of that object in coreos example waybill prefixes for a client are generated based on predetermined rules and used for any new waybills custom code implementation there are two ways to provide custom code pre configured custom code pre configured custom code can be registered using the handlers it will be invoked before calling the api and applied for all the requests for a type in the request body custom code can be passed along with the request body if it has to be applied for a single request such as a create/update instance there are two attributes added for all non get apis (except types) attributes onrequest the request body of the onrequest customcode url is the input of the api no custom request body can be passed for the onrequest customcode api call if onrequest fails, onerror is executed notification is not sent if onrequest fails onerror the request body of the onerror customcode url is the input of the api error message related to the onrequest api call is passed for the onerror customcode api call if onerror fails, the custom api response will be returned as a new field customapiresponse notification is not sent if onerror fails