Passing a list as a screen input parameter
Application Type
Reactive

Is there anyway to pass a text list as an input parameter to another screen?

Solution

Hello  Tenisha Lovell,

Welcome to Outsystems Community,
If I understand your question right , then you can use JSON Serialize & JSON to achieve this

Same question was asked before you can check the post from the links below -

https://www.outsystems.com/forums/discussion/53751/structures-as-input-parameter-of-a-screen/ 

And this blog can also help -
https://itnext.io/serializing-deserializing-json-in-the-outsystems-platform-ae08f2f6b5b4

I hope this may help you.

Thanks & regard

Tousif Khan

Thank you.

mvp_badge
MVP

Though this works, be aware that there's a limit to the amount of data that can be passed. The parameters of a Screen are passed in the URL of the Screen, and there's a maximum of about 2048 bytes. See e.g. here for a discussion. So only use this if you can be certain the total size of the JSON is well below that limit.

Hi Tenisha,

As in Outsytems we cannot pass a list as input parameter for screen.

However, you can use String_Join to convert a text list to a string with a separator (such as special character like ";", or "," , etc...) then pass it as input parameter. After that OnInitialize you can use String_Split to convert back to list of text.

Hope this helps,

Khuong

This is pretty smart actually. I did a work around and created an entity to keep track of it and delete records when finished.

mvp_badge
MVP

Two observations:

  1. I'd personally use JSON Serialize/Deserialize instead of String_Join, especially because String_Split will fail if there's a seperator character inside the actual data, and;
  2. The reasons that you cannot pass lists is that the parameters of a Screen are passed in the URL of the Screen, which means there's a limit as to the amount of data that can be passed.
Champion

Hi Tenisha, 

Input parameters of screen support only basic data type. It is not possible to pass a list.   You can follow the above answers for alternatives. But It is not the best practice to pass large text from one screen to another because it is the cause of network latency. 


Please share your use case and more details, why do you want to pass the list? 


Best Regards, 

Rahul Kumar




Hi @Rahul Kumar ,

I need one clarification ..i  want to pass this payload to rest API..can you give me some ideas ..how can i pass this below format JSON file from the frontend... mainly that "qnaList" part format


{

  "add": {

       "name":"test1",

    "qnaList": [

      {

        "id": 0,

        "answer": "fine",

        "source": "Custom Editorial",

        "questions": [

          "how are you?"

        ]

      }

    ]

  }

}

mvp_badge
MVP

Hi Vigneswaran,

You are replying to an old(ish) topic that already has an answer marked as solution. This means your new post will get very little attention from the community. In these cases it's best to just start a new topic!

That said, in OutSystems, REST services send JSON based on the Structures that you define. This means your JSON must be converted to a Structure, and that Structure must be used in the REST method. Luckily for you, Service Studio can create a Structure based on JSON. To do so, go to the Data tab, and locate the Structure folder. Open the context menu by right-clicking and choose "Add Structure from JSON...". In the pop-up, paste your JSON, give the Structure a name and press the "Add Structure" button. You'll see a Structure is added, like this:

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.