Hi,

I'm have a list of column names (let's say there are more than 200) and I want to create a Structure for it. There isn't any Entity with the same columns so I can't copy and paste them to my Structure.

I see that there is an "Add structure from JSON" option. And I've tried to use it, but I don't fully understand it. I tried to look for documentation about how to use it, but there is none. How do I add other information for my Structure Attributes like Description, Label, Data Type, Length...? Is that possible to do with this JSON option? Because I can only make a Structure Attribute with basic info like Name.

If it's not possible with this JSON option, what is the fastest way for me to create Structure with lots of Structure Attributes in OSP?

Thanks

Hello Loi,

Do you mind sending an example of your JSON file?

I tried with the following

{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}


And all the structures were created

If you have an XML you can convert this XML to json using a online tool and then import the json

Hi Loi,

There's no way to do what you want except manually. Note that in general, having Structures with so many Attributes points to design errors...

@Jay Santos

Actually I just want a simple Structure with lots of Attributes on it.

Example:

{ 
 "id": "file",
 "value1": "file",
 "value2": "file",
 "value3": "file",
 "value4": "file",
}

Btw, how can I set the Data Type for each of the Attribute?
I tried your code and "file" made the Attribute Data Type "Text", how can I change it to "Integer", "Decimal". etc...
Is there a documentation anywhere, because I couldn't find it. Thanks!

@Erik

Sr, I don't have the XML for it. What I tried is that I turn all the column names into csv, then converted them to json and import them. So far so good. But what I want to know is how to set other properties of Structure Attribute without having to input them manually on the Platforms, because that will be the quickest way of create Structure I found.

@Kilian

I see, so what I can only do is like I said above to quickly generate Structure with lots of Attributes. For other properties, I have to manually input them. I just hope there is other way than that. And more documentation on how to use the Platform.

@Everyone

So other than JSON, is there any other way I can create Structure quickly?

Thanks

Hi Loi Hua,

I don't think we have any other option than manual creation and JSON.


Sravan 

Solution

Hi Loi,

OutSystems guesses the data type from the JSON. So if the JSON value is "string" it's Text, if it's 0 it's Long Integer, if it's 0.0 it's Decimal, if it's true it's Boolean, if it's 2019-04-17 it's Date, and if it's 2019-04-17T08:40Z it's DateTime.

Other Properties, like length, need to be set manually.

Solution

@Sravan
Well, thank you for your info :) Guess I'll have to try and find my own way.

@Kilian
I tried to what you suggest, and some of it worked like Text, Long Integer, Decimal and Boolean. Other like Date, Time, DateTime and Integer, I have no luck.
Can you share your sample JSON? Here's what I tried.


Hi Loi,

You need to add quotes around the date and date time literals, I forgot to add them in my previous post. I have no luck auto-creating a Time Attribute, "00:00:00" just stays Text. Any integer value will create a Long Integer, it's not possible to auto-create Integers.

Only to add

For Time type, it works

"Time"    : "12:10:05",

What I could not achieved is to get DateTime

Ok I get it! 


if I used 

"DateTime": "2019-02-15T12:10:05",


I get DateTime format, as Kilian has said


Oh my... it seems "Time" only works with hours <=12 :)

That's it!! I think must be reported to OutSystems

Already did :)

Hey guys, thanks for all the answers.

I'll just do what I can for now!