Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7568 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi

I have delibrately taken off add new company from the startup layout on my database so people need to look before adding a company. Is there anyway that after a search reveals no returns that I can offer an option box to add new company, i.e run a script???

Or is there a better way?

Thanks

Simon

Posted

Simon,

Write a find script, such as

Set Error Capture [On]

Enter Find Mode []

(Then perform your find for the company)

If ["Status(CurrentError) = 401"]

Show Message [ Company Not here. Would you like to create company?]

(Or you could use Show Custom Dialog if you are using FM 6)

If ["Status(CurrentMessageChoice) = 1"]

NewRecord/Request

Else

ShowAllRecords

Exit Script

End If

End If

Hope this helps

Dean

Posted

I do something similar with book titles. If your companies have a unique ID that will be manually entered by the user (as opposed to an auto-serial field), this will work. For books, they all have ISBN numbers, so the unique ID is set ahead of data entry. If you don't, then you should use a field for a new company that will be unique to the company, like street address or company name. This could be a problem if the data entry isn't exact. Here are two variations on both, for example:

Acme Co.

Acme Company

123 Main St.

123 Main Street

These will both fail the attempt to locate an earlier record for this company. But, assuming the data is exact, and calling the company name field CoName for the purpose of this example, you could set up a self-join relationship based on CoName and a global user entry field I'll call g_CoName. Have the user run a script that will not make a new record (yet) but place them in the g_CoName field and pause. They fill in the company name and hit the enter button or click Continue.

Then you have a test for a previous record based on the self-join between the global and CoName

If (IsValid(Self-Join::CoName)

Show Message ("Company already exists.")

**Do whatever else you need**

Exit Script

Else

New Record/Request

**Data entry stuff*

End If

If you need to direct the user to the previous record at the point a match is made, under the Show Message you could put a Go To Related Record (Show, "Self-Join"). This will leave the user on the older record that was about to be duplicated as it exits the script.

Note that this test happens before a new record is created, via the global field. This way, if there is a match, you don't have an extraneous new record that needs deleting.

Steve Brown

This topic is 7568 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.