How to get the text name of a structure attribute?

How to get the text name of a structure attribute?

  

How do you get the attribute name of a structure?

Example

Structure

"MyItem" structure record has 1 attributes "Description"

Action

MyAction has 1 input parameter "Field" and 1 output parameter "ReturnFieldName"


MyAction, input parameter is assigned attribute "MyItem.Description" and returns the text "Description" via "MyAction.ReturnFieldName" output parameter. 


But how do you do this? any action to get the name of a structure attribute? Is it even possible to do this via an extension?


Hi Robert,

Yes, via an extension you can get the names of the attributes. It's done in various extensions that handle record lists, e.g. SortRecordList and XMLRecords. I think the .NET name for that pattern is "reflection", don't know what it's called in Java. You can't otherwise get names of e.g. parameters (although names of screen parameters may be extracted from the URL).

May I ask what your use case is?

Killian

Not possible to pass a structure attribute and gets its name via extension or via service studio.

It looks like I have t type the structure name manually.


This task is too complicated for outsystems platform, it just wouldnt work, there is no solution.

Robert,

I'm not talking about passing a structure attribute, which is nothing more than a variable value, I'm talking about passing a Record or Record List. In that case, it is possible to get all the attribute names.

But again, what's your use case?

Use case:

There is a public JSON web service

The public JSON web service request is converted to an outsystems structure.

Certain fields/attributes are mandatory (just like when a user fill out an edit record, some input fields are mandatory, if they are not filled in by the user a response is provided) 

Most web services response contain the following common "Response"




      • {
          "Response": {
            "Success": true,
            "Timestamp": "2014-12-31T23:59:59.938Z",
            "Build": "string",
            "Errors": [
              {
                "Code": "string",
                "Type": "string",
                "Message": "string",
                "DetailedMessage": "string",
                "Property": "string"
              }
            ],
            "Message": "string",
            "Language": "string"
          }
        }



    "Errors": [
      {
        "Code": "error response code",
        "Type": "type of error bad_request etc",
        "Message": "short message",
        "DetailedMessage": "long message",
        "Property": "this is the structure attribute name where the occur occured"
      }


When an error occurs the following response is returned in the error list

    "Errors": [
      {
        "Code": "400",
        "Type": "bad_request",
        "Message": "Last name required", <-- need get this from structure attribute
        "DetailedMessage": "Enter your legal family name",
        "Property": "LastName"  <-- need get this from structure attribute
      }


Every error message is manually entered, there needs to be an easier way to do this.


Right now each error is created with an action: RestToolKit\RestToolKit\Errors_BuildErrors (attached)

With a "JSON webservice" you mean REST? If so, are you using the Platform's REST capabilities? Or are you using ardoJSON for parsing? (I'm currently not able to take a look at the .oap).

Kilian 

Using outsystems rest expose. 

When you use outsystems forms via a Web scrern you can validate the form  via a screen action. When you build a website service you would need to validate the Web service request (expose rest) 

Robert,

REST expose is for exposing a REST service. You were talking about a public REST service, isn't that REST consume then? If so, I still don't understand why you need to know the name of an attribute of a structure...

Kilian 

REST expose, instead of manually typing each and every attribute name, I want to just read the name 

This is to set the "Error.Property" field in the REST expose method. 

There's alot of other things I want to do, but must do repeative manual task  for now. 

Well, I still don't get it, call me dumb :).

I don't think you are dumb. If I called you on Skype, and explained it to you, you will get it instantly  :) 


(it might also  help to look at resttoolkit) 


I don't want to manually type the names of the attribute anymore to set the error record.