I need to map engineer details by HTML type field

Priya Singh 2 2
Tera Contributor

Hi Team, I have got requirement to map the data which is coming from 3rd party through e-bonding integration in the below format - 

PriyaSingh22_0-1706078995396.png

there are total 19 engineers which I need to map with HTML field ex - Engineer_2, Engineer_3..............................

I want result to be shown in tabular format - 

Name            Email             Phone Number                Company

whatever engineer detail is coming from third party, how can I achieve this requirement ?

4 REPLIES 4

Vishal Birajdar
Giga Sage

Hello @Priya Singh 2 2 

 

Can you let us know where do you want this functionality native UI form  or Service catalog...??

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Native UI

Hello @Priya Singh 2 2 

 

Can you try below code....

 

Here I have written business rule

 

(function executeRule(current, previous /*null when async*/ ) {

/* 1. Assuming you are getting data like this */
    var responseData = {
        'engineer_1': ['Vishal', 'xyz company', '12345', 'test1@example.com'],
        'engineer_2': ['Birajdar', 'abc company', '54321', 'test2@example.com']
    };

    /* 2. get Kays will use it to iterate through kay Array*/
    var keyArray = Object.keys(responseData);  //here we will get the array of keys ['engineer_1','engineer_2']

    /* 3. Declare tableData variable*/
    var tableData = '';
    
	/* 4.Create table header */
    var tableHeader = '<p>&nbsp;</p><table style="border-collapse: collapse; width: 99.9463%; height: 153.958px;" border="1"> <tbody><tr style="height: 15.3958px;"><th style="width: 22.8193%; height: 15.3958px;"><strong>Name</strong></th><th style="width: 22.8193%; height: 15.3958px;"><strong>Email</strong></th><th style="width: 22.8193%; height: 15.3958px;"><strong>Phone number</strong></th><th style="width: 22.8193%; height: 15.3958px;"><strong>Company</strong></th></tr>';
    
	/* 5.Iterate through kay array & set Table data */
    for (var i = 0; i < keyArray.length; i++) {

        if (tableData != '') {
            tableData = tableData + '<tr style="height: 15.3958px;"></td><td style="width: 22.8193%; height: 15.3958px;">' + responseData[keyArray[i]][0] + '</td><td style="width: 22.8193%; height: 15.3958px;">' + responseData[keyArray[i]][1] + '</td><td style="width: 22.8193%; height: 15.3958px;">' + responseData[keyArray[i]][2] + '</td><td style="width: 22.8193%; height: 15.3958px;">' + responseData[keyArray[i]][3] + '</td>';
        } else {
            tableData ='<tr style="height: 15.3958px;"></td><td style="width: 22.8193%; height: 15.3958px;">' + responseData[keyArray[i]][0] + '</td><td style="width: 22.8193%; height: 15.3958px;">' + responseData[keyArray[i]][1] + '</td><td style="width: 22.8193%; height: 15.3958px;">' + responseData[keyArray[i]][2] + '</td><td style="width: 22.8193%; height: 15.3958px;">' + responseData[keyArray[i]][3] + '</td>';
        }

    }
    
	/* 6. Set table end */
    var tableEnd = '</tbody></table>';
   
    /* 7.Set current forms html field. In my case its 'text' (Article body) field in knowledge article form*/
    current.setValue('text', tableHeader + tableData + tableEnd);

})(current, previous);

 

Output : 

VishalBirajdar_0-1706086197939.png

 

Hope this helps....!!!

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Thank You for your response, could you please confirm which BR type I need to select, and operation.

 

I want this data to be shown when I click on a field called other Engineer how this will be validated ?