Want to know how to add switch case in visualizer

How to show a different value against TypeId in visualizer in Table. I can display data in table however i want to add description against TypeId
{
“Array”: [
{
“ReturnCode”: “0”,
“BillNo”: “B1”,
“BillDate”: “2021-06-09T00:00:00”,
“TypeId”: “4”
},
{
“ReturnCode”: “0”,
“BillNo”: “B2”,
“BillDate”: “2021-06-01T00:00:00”,
“TypeId”: “27”,

    } 
]

}

Hi @manish_runapp,

As per your problem statement, you may try to have JSON data as lookup values and can assign those values as an alternate to ids.

Hey @pranavdavar not clear . Can you help me with example. I am using below template. For Type ID in below template i have to render one string value
var template = `

<style type="text/css">

    .tftable {font-size:14px;color:#333333;width:100%;border-width: 1px;border-color: #87ceeb;border-collapse: collapse;}

    .tftable th {font-size:18px;background-color:#87ceeb;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;text-align:left;}

    .tftable tr {background-color:#ffffff;}

    .tftable td {font-size:14px;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;}

    .tftable tr:hover {background-color:#e0ffff;}

</style>



<table class="tftable" border="1">

    <tr>

        <th>Bill Date</th>

        <th>Bill No</th>


        <th>Net Payable</th>

        <th>TransctionTypeID</th>

     
        

    </tr>

    

    {{#each response.MemberTransactionResponseListDTO}}

                        

            <tr id=row_{{@key}} onClick="handleClick(this.id)">

            <td id={{@key}}>{{BillDate}}</td>

            <td>{{BillNo}}</td>

     
             <td> {{TotalBilledAmount}}</td>

             <td> {{ TypeID}}</td>

        

            

             </tr>

                           

        </tr>

                                        

    {{/each}}

</table>

`;

pm.visualizer.set(template, {

response: pm.response.json()

});

Hi @manish_runapp,

I have updated the script. You may try to customize as per your requirement.

var t = {

    "4": "test",

    "27": "test2"

};

var demo = {

    "Array": [

        {

            "ReturnCode": "0",

            "BillNo": "B1",

            "BillDate": "2021-06-09T00:00:00",

            "TypeId": "4"

        },

        {

            "ReturnCode": "0",

            "BillNo": "B2",

            "BillDate": "2021-06-01T00:00:00",

            "TypeId": "27"

        }

    ]

};

var arr= demo.Array.map((element)=>{

    element.t1=t[element.TypeId];

    return element;

});

console.log(arr);

var template = `<style type="text/css">

    .tftable {font-size:14px;color:#333333;width:100%;border-width: 1px;border-color: #87ceeb;border-collapse: collapse;}

    .tftable th {font-size:18px;background-color:#87ceeb;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;text-align:left;}

    .tftable tr {background-color:#ffffff;}

    .tftable td {font-size:14px;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;}

    .tftable tr:hover {background-color:#e0ffff;}

</style>

<table class="tftable" border="1">

    <tr>

        <th>Bill Date</th>

        <th>Bill No</th>

        <th>Net Payable</th>

        <th>TransctionTypeID</th>

     <th>TransactionValue</th>

        

    </tr>

    

    {{#each response}}

                        

            <tr id=row_{{@key}} onClick="handleClick(this.id)">

            <td id={{@key}}>{{BillDate}}</td>

            <td>{{BillNo}}</td>

     

             <td> {{TotalBilledAmount}}</td>

             <td> {{TypeId}}</td>

             <td> {{t1}}</td>

        
            

             </tr>

                           

        </tr>

                                        

    {{/each}}

</table>`;

pm.visualizer.set(template, {

    response: arr

});

Let me know if this solves your purpose :slight_smile:
Hope this helps :slight_smile:

3 Likes

This works like Magic. I appreciate the approach. I left coding long time back however this was fun :slight_smile:

2 Likes