finding duplicates and offering choices

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
tkilshaw
Posts: 170
Joined: Thu Jan 19, 2006 11:33 pm
Location: Western Canada
Contact:

finding duplicates and offering choices

Post by tkilshaw »

When a new Contact instance is entered, before the record is actually created, I want to check for duplicates. A duplicate is where Contact.FirstName and Contact.LastName match.

The following code does that:

If EXISTS Contact WHERE (TO_UPPER_CASE(Contact.FirstName)=TO_UPPER_CASE(ThisContact.FirstName) AND TO_UPPER_CASE(Contact.LastName)=TO_UPPER_CASE(ThisContact.LastName)) Then
REPORT ERROR 'Contact with the same first and last names already exists.'

But I don't want to report that as an error, I want to display the list of matching Contacts, allow the user to either choose a matching record to replace the one that was being created, or to dismiss the list of matching contacts and continue with the creation of the new Contact.

Is this doable in Aware? If so, How?

thanks,

Terry
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

Terry,

I'm not sure what you mean by "replacing" the record with the matching record. Let's assume that you want to insert a Contact as a reference into some other object (Parent), so you are creating a new instance of the Contact and then if you find matching records you offer a choice to the user. If the user chooses the matching record, that record is inserted in the Parent instead of the record that has been just created. This is how you could do this:

This is the text of the process accepting Parent as input:

ENTER NEW Contact
If EXISTS Contact WHERE (....) Then HandleMatching USING Parent,Contact
ELSE INSERT Contact IN Parent.Contacts

The text of the HandleMatching process that takes Parent and Contact as input:

DISPLAY QUESTION 'Matching records found. Do you want to choose the matching record?'
If Question.Reply='Yes' Then
PICK FROM Contact WHERE (...)
INSERT ThatContact IN Parent.Contacts
DELETE ThisContact
ELSE
INSERT ThisContact IN Parent.Contacts
EndIf
Aware IM Support Team
tkilshaw
Posts: 170
Joined: Thu Jan 19, 2006 11:33 pm
Location: Western Canada
Contact:

Post by tkilshaw »

I was very intrigued by the code example you gave. I see here that a USING expression is appended to the process call. I'm really not sure why. I thought that processes that run sequentially automatically inherit their predecessor's context - though there have been times when I have been unable to make that work for me. So the USING clause here appears redundant.

Is it redundant?

The manual says:
>>>>>>>>>>>>
If a process requires process input then instances of the business objects representing the process input will be automatically taken from the current Context when the action is executed. It is also possible to explicitly indicate this input, for example,

If Policy.State = ’Open’ Then CalculatePremium USING Policy

The process input must be used explicitly in the action if it represents a reference attribute. For example,

If Customer.CurrentPolicy.State = ’Open’ Then CalculatePremium USING Customer.CurrentPolicy
<<<<<<<<<<

I guess this means that "USING Customer.CurrentPolicy" puts the CurrentPolicy instance into the context?

------------------------

Here is what I'm trying to do.

The user wants to add a new account. They do this by clicking on a menu item that starts the process "Account_Add". This is currently defined as:

ENTER NEW Account USING Main
DISPLAY MESSAGE 'Account `'+Account.AccountID+'` was created'
View Account USING Main

With the Account form on the screen they click on the "Add new item" button on the Main Contact reference. I mean here the small button that Aware generates automatically for reference items. That will display the entry screen for a Contact. When the Contact form's Create button is clicked I want to detect if the new Contact matches any existing Contacts. For the sake of this example, lets say its a match if the last names are equal and if the first names start with the same letter.

At that point I want to display a list of potential matches.

If they select a Contact from the list, that Contact will become the Account's Main Contact.

If they don't select a Contact from the list, the record they were in the process of creating will be created and will become the Account's Main Contact.

So far, I can't see a way to do this. Mostly because I can't get my hands on the process that adds the Contact to the Account.

thanks,

Terry
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

Terry,

1. You are right about USING - it is redundant. I guess I included it purely for the illustration purposes.
2. I would recommend a slightly different approach to what you are trying to do. Rather than showing the full form of the Account to the user I would show a special form that contains a bare minimum of the information that the user needs to enter to create a valid account. Is it possible not to include the Contact in this information? Once the account has been created I would proceed to the next step - creation of the Contact. So the process would look something like this:

ENTER NEW Account USING 'Some special form'
DISPLAY QUESTION 'Do you want to create the main contact?'
If Question.Reply='Yes' Then ...
The rest is similar to the process I described in the previous message

Will this approach work?
Aware IM Support Team
tkilshaw
Posts: 170
Joined: Thu Jan 19, 2006 11:33 pm
Location: Western Canada
Contact:

Post by tkilshaw »

We don't consider your suggestion to be a good approach. Easy of initial Account creation is very important.

Your suggestion forces a two stage process on the user, and makes them use buttons above or below the main Account form to add a Contact and Company, both of which need to be checked for duplicates.

At this point I'm characterising this as a training issue.

Aware gives us Add and Add New buttons. Users should be trained to use the Add button first to look for matching Contacts. Problem is that this will be labourious whe there are several thousand Conact records.

thanks,

Terry
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

In 1.6 we will add a functionality that will allow you to override the default Aware IM behaviour of adding references. You will be able to specify your own process to handle adding of references. In this process you can create a new reference, check for duplicates, prompt to select duplicates if required and finally add a reference to the object being created or updated.
Aware IM Support Team
tkilshaw
Posts: 170
Joined: Thu Jan 19, 2006 11:33 pm
Location: Western Canada
Contact:

Post by tkilshaw »

Thankyou. That sounds like it may deal with this problem quite well.

Terry
ab042
Posts: 326
Joined: Mon Jul 17, 2006 4:11 am

Post by ab042 »

I need this same type of logic and you make reference to adding the ability to better handle it in v1.6 (ie: "check for duplicates, prompt to select duplicates if required and finally add") but I'm not sure I have come across any automated features for it in v2.x.

Does documentation exist on this somewhere or is this in reference to something other than checking for duplication of records that a user is keying??
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

This is available in version 2.0 as a custom process to add references. If you go to the Presentation of a reference attribute and to the "Add Item" or "Add New Item" settings you will find the ability to specify your own process of adding references, instead of using the pre-built one.

In this custom process you can check for duplicates etc etc.
Aware IM Support Team
Post Reply