Highlighted
Honored Contributor.
Honored Contributor.
218 views

Preventing Duplicate Results in Searches

I am using HPE Service Manager 9.50. I want to create field to allow users select a City. The list of cities to choose from, I would like pulled from the location table.

Here is my challenge. We have multiple locations with the same City, how can I get the selection to only show 1 name for each city?

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Preventing Duplicate Results in Searches

What is the field type and query you are using?

If you have 10 location records all with a city of New York, how will you decide which location record should be the one that shows up? Do you not care which location record is actually chosen?

If you find that this or any other post resolves your issue, please remember to click "Accept as Solution". If you are satisfied with anyone’s response, please remember to give them KUDOS by clicking on the "thumbs up" at the bottom left of the post to show your appreciation.
0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Preventing Duplicate Results in Searches

It's not really the entire location record that I want to select it's just the City. I would be tempted to create a separate record with just Cities, but I do not want to have to keep that updated when I already have a list of the Cities I need in the location table.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Preventing Duplicate Results in Searches

In case you're still working on this, I had some time to investigate further. There may be a simpler way to achieve this, but here is a method that works in my basic testing:

This example is based on the out of box "Location" field on the out of box im.incident.logging format. Even though the field is designed to store the actual location, we will use it to store the city (just for ease of testing).  Feel feel to adapt it your environment/situation as necessary.

NOTE: Please make a backup of all records referenced below in case you need to restore them for any reason.

Here are the steps I used:

1. Log in to the Client as a SysAdmin

2. Tailoring > Tailoring Tools > Links

3. Name:probsummary

4. Search

5. Locate the link line that says location.full.name location location.full.name $ln.query (should be the 2nd of the 3 location.full.name link lines)

6. More > Select Line

7. Edit the link line as follows:

a) Remove all existing expressions (this is just for testing purposes, if you need to retain any of the existing ones they can be added back after testing is successful)

b.) Add the following expression:

if (not  (null(location.full.name in $File))) then ($ln.query="location=\""+jscall("FirstCity.findFirstLocation", location.full.name in $File)+"\"")

c) Locate the the Source Field (Fill To/Post From) line with location.full.name

In the Target Field (Fill From/Post To) for this line change it from location.full.name to city

d) Save

8. Tailoring > ScriptLibrary

9. Name: FirstCity

10 Package: Base Utilities

11. Add

12. Enter the following code in the ScriptLibrary record:

//var locationQuery;
function findFirstLocation(query)
{
//print( "Searching for location starting with " + query + "..." );
var locationFile = new SCFile( "location",SCFILE_READONLY );
locationFile.setFields("city");
var findLocation = locationFile.doSelect( "city#\""+ query + "\"" );
if ( findLocation == RC_SUCCESS )
{
//print( "Success. Found location starting with " + query + "." );
var findFirstRecord = locationFile.getFirst();
//print( "The first record is:\n" + locationFile );
//print( "The city in the first record is:\n" + locationFile.city);
return locationFile.location;
} else
{
//print( "Could not find location starting with " + query + ". " + RCtoString(
return null
}
}

13. Save

14. Incident Management > Create New Incident

15. Enter some text in the location field for the city. For example, I added a new location record with Cape Town as the city. There is already an existing location record with a city of Cape Town.

16. Click the Fill button.

RESULT: The proper city should be chosen from the first location record that has that city populated. 

 

 

 

If you find that this or any other post resolves your issue, please remember to click "Accept as Solution". If you are satisfied with anyone’s response, please remember to give them KUDOS by clicking on the "thumbs up" at the bottom left of the post to show your appreciation.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.