Field action with REST API

SOLVED

Hi all,

Is there a possibility to execute field actions using REST API?

Best Regards

Parents
  • 0
    SUGGESTED

    It really depends on what you are trying to achieve, REST is based on representations and classes, field actions come from the classic environment, can you please describe in more detail, maybe than we can suggest a shortcut. Thanks.

  • 0 in reply to Martins de Almeida

    Hi Martins,

    Actually, I come from the old school of X3 programming. I still don't really understand the advantages of using Representations and classes over Masks and Windows. 

    Our need is to create and modify records of several X3 objects using a third-party application. The communication protocol would be Web Services.

    I want to be sure that when I create a new record, all standard and specific actions will be executed.

    Also, in the third party application, I want to execute field checks on each field in the 3party app before sending the create query. the aim is to guide the user while he/she inputs data.

    I hope that I explained clearly what I want to achieve.

    Best regards

  • +1 in reply to TopX3
    verified answer

    Yes, understand now.

    I think you would not get this easily, the first part, the same business logic... 2 options on the fly: 1 - replicate the code in classes, so when you call create record in REST it will run the same logic; 2 - Create a Class/Representation (Shadow of the object you want to create) just to receive the request, then generate a file and import as an import model, as we do in standard, this way the class will be the request and the classic object will be the same object as you have;

    Regarding the the field checks problem, usually we do this by creating specific views with columns and filters as necessary, and then you create a class and representation over the view and therefore you can then call the REST webservices with the result you want. This is a blind suggestion, if you give us some more info, maybe we can provice more efficient solution.

    This reply is based on our experience around classes and representations, believe it is very handy, these days we build a lot around hybrid objects, using the mask and windows interface, but then using classes for the server business logic, easier to manage multiple child and easier to control the behavior and business logic. Initially it takes more time, and usually developers are afraid of change...

    If you need specific support call me on teams ([email protected]), we can show you some examples we did to communicate with a website for stock online. Cheers.

  • 0 in reply to Martins de Almeida

    Hi Martins,

    Thank you very much for this valuable information.

    I must first learn the concepts of class and representation before I start using the REST protocol.

    Thanks again

Reply Children
  • 0 in reply to TopX3

    Yes, that's mandatory...

  • 0 in reply to TopX3

    Hello, TopX3

    Just a little note on the REST API: it is stateless. That means you do not have a classic session with all the global variables initialized. Which also means many (if not most) standard field actions will not work.

    It would be possible (but not viable) to initialize all the necessary variables, screens, tables, etc.. but the overhead for each request would be HUGE as you can imagine.

    Martins de Almeida's solutions are viable.

    Also (although it may not be a possibility in your cenario) if a very quick response is not needed for the record creation/modification in X3 I would suggest implementing basic validations for the most obvious errors and/or limit the possible data the user can input for each field (similar to Martins' suggestion of creating a view). Then, create a staging area with the request to create/modify the record that is handled by a batch task in X3 (which runs every x minutes or the request creation can schedule the task if it is not already scheduled). The request is then updated with the result of the batch task (success or an error with a message) and the record/request in your app can get its status updated. All these interactions can be implemented using classes/representations except the batch task... that would have to be classic code to simulate the standard object by importing a file or through other means like simulating Soap WebServices (easier to modify the records and get error messages, or even simulating left-list picking). 

    Regards,
    RN