The CreatorCon Call for Content is officially open! Get started here.

Can you find the highest integer value using a flow?

Moedeb
Tera Guru

I have an integer field on the sys_user table called "u_queue_number".

What I want to do if possible via a flow is to seek out all records where u_queue_number is not blank and find what the current highest value of that field is and also how many records current have that value.

 

Ideas?

1 ACCEPTED SOLUTION

@Ankur Bawiskar 

I understand that it would likely need to be done via a flow script, but was hoping someone might be able to assist with the how.

Since I posted my question I have managed to make it work, but just not sure it's the best way to do it?

Ultimately, I created a flow variable called "Highest Queue Number" then did a scripted date 

 

Moedeb_1-1739764593416.png

 var largestQueueNumber = 0;
    var userGR = new GlideRecord('sys_user');
    userGR.addQuery('u_queue_number', '!=', '');
    userGR.query();
    
    while (userGR.next()) {
        var currentQueueNumber = parseInt(userGR.u_queue_number, 10);
        if (!isNaN(currentQueueNumber) && currentQueueNumber > largestQueueNumber) {
            largestQueueNumber = currentQueueNumber;
        }
    }
    return largestQueueNumber;

 

Result:

Moedeb_2-1739764860967.png

So it works, but is it the best way?

View solution in original post

5 REPLIES 5

@neetusingh 

I like the idea of improving the script to limit the database calls, however when I tried this in a flow I got the following error:

Invalid integer value for flow variable='null': {highestQueueNumber=5.0, countOfHighest=0}

 

The script is running in a set flow variables script