Skip to main content
June 28, 2023
Question

Dynamic UI components building using API JSON response

  • June 28, 2023
  • 19 replies
  • 0 views

I have to create Dynamic UI meaning based on the API JSON response received.

I will be receiving the input type like check box or input and all the other attributes in JSON response, using that can i create the component and create dynamic UI?

    19 replies

    harshitb6843
    June 28, 2023

    You can but this will not be very robust or as dynamic as you visualize it to be. Also, every component in Appian is mapped with a variable where it will store the response/interaction. That will be done in a dictionary instead of a variable now. 
    I'll attach a code sample below in the next comment. 

    June 28, 2023

    Thank you for the update.
    Kindly share the sample code. And one more doubt when we the receive the UI component as API response.

    Will we be able to create interface with Appian available components or it is feasible to create interface using custom component received via API response?

    And also can you share any document or link to understand and implement the same.

    stefanhelzle0001
    Brainy
    June 28, 2023

    If you HAVE to do that, then yes, it can be done. Just create a UI component for each UI element in your JSON.

    But, in my experience this is not a good way to make use of Appian and will lead to serious issues and major development effort later on.

    June 28, 2023

    Thank you for the update.
    Kindly share the sample code. And one more doubt when we the receive the UI component as API response.

    Will we be able to create interface with Appian available components or it is feasible to create interface using custom component received via API response?

    And also can you share any document or link to understand and implement the same.

    stefanhelzle0001
    Brainy
    June 29, 2023

    I do not have sample code I could share, but the pattern is to use the choose() function to check for the UI components you need and then for each, use the Appian UI components to build them. Then, run this expression in a foreach() to create that UI.

    This is not a simple endeavour that includes some edge cases of what can be done with Appian.

    And when you start thinking about doing this using custom components, which is feasible, I have to ask, why exactly do you want to use Appian?