Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get the values from HTML table from an email in a Inbound Action

sivareddy
Tera Contributor

Hi All,

 

How to retrieve a value from HTML Table. I need to get the User Name.

 

sivareddy_0-1715251639414.png

 

Regards,

Siva

1 ACCEPTED SOLUTION

Hello Guys @Ansh1 , @sivareddy ,

 

Apologizes for the late reply. I was stuck in someother work. Here we go. I just worked with your HTML and pasting the code below to print the User Name --> Creddy.

 

Cheers🥂.

 

var html = 'Your HTML Code';
var splitHtml = html.split('</td>');
var count = 0;
for (var i = 0; i < splitHtml.length; i++) {
    if (splitHtml[i].includes('User Name')) {
        count = i + 1;
    }
}
var result = splitHtml[count].replace(/<[^>]*>/g, '').replace('&nbsp;&nbsp;', '').trim();
gs.info(result)

 

Regards,

Dhanraj.

View solution in original post

7 REPLIES 7

sivareddy
Tera Contributor

Hi @dhanrajb Please reply to the above thread

Ansh1
Tera Contributor

@dhanrajb 

We would like to Extract the 'User Name' that is 'creddy' here in the attached HTML. Request you to share the code for this.


Regards,

Ansh

Hello Guys @Ansh1 , @sivareddy ,

 

Apologizes for the late reply. I was stuck in someother work. Here we go. I just worked with your HTML and pasting the code below to print the User Name --> Creddy.

 

Cheers🥂.

 

var html = 'Your HTML Code';
var splitHtml = html.split('</td>');
var count = 0;
for (var i = 0; i < splitHtml.length; i++) {
    if (splitHtml[i].includes('User Name')) {
        count = i + 1;
    }
}
var result = splitHtml[count].replace(/<[^>]*>/g, '').replace('&nbsp;&nbsp;', '').trim();
gs.info(result)

 

Regards,

Dhanraj.