cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Akobir
Frequent Visitor

How to change type of variable in JS

Hi Everyone!

I have a JS, that return me an array

 

 

function getRequests() {
  let searchInSubject = "request"
  let searchInSubjectArray = searchInSubject!==null ? searchInSubject.split(',') : [];
  let content = document.getElementById("frame_content").contentDocument.body.innerHTML;
  let requestLinksArray = [...content.matchAll(/onmouseover[^>]*(\/servicedesk\/view\/[0-9]{1,})[^>]*>([^>]*)<\/a>/g)];

  let result=[];

  for(let link of requestLinksArray)
    {
    let url = link[1];
    let subject = link[2];
    
    if(searchInSubjectArray.length==0)
      {
        result.push([url, subject])
        continue;
      }
    
    for(let search of searchInSubjectArray)
      {
        if(subject.toLowerCase().indexOf(search.toLowerCase().trim())>=0)
          {
          result.push([url, subject])
          break;
          }
      }
    }
    
    return result;
}

 

 

I used "Run JavaScript function on web page" activities, but it returns me Text.

 

I wanted to use after "For each" activities, but it don't work with text.

What I need to do to resolve this problem?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
tkuehara
Super User
Super User

Hi @Akobir 

 

You can change your variable to a list by splitting your text result.

tkuehara_0-1626701315810.png

 

View solution in original post

2 REPLIES 2
tkuehara
Super User
Super User

Hi @Akobir 

 

You can change your variable to a list by splitting your text result.

tkuehara_0-1626701315810.png

 

Akobir
Frequent Visitor

I thought that it can have easier solution. 🙂

Ok, thanks!

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Top Kudoed Authors
Users online (3,147)