Multi Row Variable Set need to pass list collector values to HTML field table

kmolson73
Tera Expert

We currently have a record producer that contains a multi row variable set with different types of variables in it. We have an HTML field on the record that the labels and values get passed to in table form when the record producer is submitted. It works great, except we recently added a list collector field (type_of_activity_vs) to the multi row variable set and I am only getting the sys_ids for the values for that field in my table. I'm trying to figure out what I need to add to my script below to be sure I get the values rather than the sys_ids. 

 

Record producer script:

//Create Table for the Additional Transaction Details
var htmlInfo = '<p></p><table style="border-collapse: collapse; width: 100%; height: 26px;" border="1"><tbody><tr style="height: 13px;"><td style="width: 33%; height: 13px;"><strong>Type of Activity</strong></td><td style="width: 33%; height: 13px;"><strong>Date of Transaction</strong></td><td style="width: 33%; height: 13px;"><strong>Account Number</strong></td><td style="width: 33%; height: 13px;"><strong>Amount</strong></td><td style="width: 33%; height: 13px;"><strong>Transaction Details</strong></td>';

var rowcount = producer.additional_transaction_details.getRowCount();
for(var rc=0;rc<rowcount;rc++){
var row = producer.additional_transaction_details.getRow(rc);

htmlInfo += '<tr style="height: 13px;"><td style="width: 33%; height: 13px;"> '+ row.type_of_activity_vs + '</td><td style="width: 33%; height: 13px;">'+ row.date_of_transaction_vs + '</td><td style="width: 33%; height: 13px;">' + row.account_number_vs + '</td><td style="width: 33%; height: 13px;">' + row.amount_vs + '</td><td style="width: 33%; height: 13px;">' + row.transaction_details_vs + '</td></tr>';
}
htmlInfo += '</tbody></table>';

current.more_transaction_details=htmlInfo;
 
See attached image for how it looks on my record. What is the best way to add the array to the above script to get the values?
 
1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @kmolson73 ,

 

Can you please try the below code in your script-

 

// Create Table for the Additional Transaction Details
var htmlInfo = '<p></p><table style="border-collapse: collapse; width: 100%; height: 26px;" border="1"><tbody><tr style="height: 13px;"><td style="width: 33%; height: 13px;"><strong>Type of Activity</strong></td><td style="width: 33%; height: 13px;"><strong>Date of Transaction</strong></td><td style="width: 33%; height: 13px;"><strong>Account Number</strong></td><td style="width: 33%; height: 13px;"><strong>Amount</strong></td><td style="width: 33%; height: 13px;"><strong>Transaction Details</strong></td>';

var rowcount = producer.additional_transaction_details.getRowCount();
for (var rc = 0; rc < rowcount; rc++) {
    var row = producer.additional_transaction_details.getRow(rc);

    // Fetch the display value for the list collector field
    var typeOfActivity = [];
    var typeOfActivityIds = row.type_of_activity_vs.split(','); // Split the list collector values

    var typeOfActivityGR = new GlideRecord('your_list_collector_table'); // Replace with your actual table name
    typeOfActivityGR.addQuery('sys_id', 'IN', typeOfActivityIds);
    typeOfActivityGR.query();
    while (typeOfActivityGR.next()) {
        typeOfActivity.push(typeOfActivityGR.getDisplayValue('display_field')); // Replace 'display_field' with the appropriate  field
    }

    // Handle single or multiple values
    var typeOfActivityDisplay = typeOfActivity.length > 1 ? typeOfActivity.join(', ') : typeOfActivity[0];

    htmlInfo += '<tr style="height: 13px;"><td style="width: 33%; height: 13px;">' + typeOfActivityDisplay + '</td><td style="width: 33%; height: 13px;">' + row.date_of_transaction_vs + '</td><td style="width: 33%; height: 13px;">' + row.account_number_vs + '</td><td style="width: 33%; height: 13px;">' + row.amount_vs + '</td><td style="width: 33%; height: 13px;">' + row.transaction_details_vs + '</td></tr>';
}
htmlInfo += '</tbody></table>';

current.more_transaction_details = htmlInfo;

 

 

View solution in original post

6 REPLIES 6

Thank you so much Sanjay! This is exactly what I needed. =D

Community Alums
Not applicable

@kmolson73 You are Welcome 😇