Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flex Question 1

Status
Not open for further replies.

Zbob

MIS
Apr 25, 2002
94
0
0
US
I need a trigger an automated email when a new customer is added.

How do I determine if a new customer has been added with flexibility?

Any Ideas (Cus start date = currentdate)......

 
Make a table, call it tblNewCust in Access containing two fields, making the CUS_NO the primary key, and a field called NewCustFlag.

Use an ADO Do loop that pulls records from ARCUST and adds them to tblNewCust. Make sure you have an error handler in your procedure:

On error goto err_h

with arcust

Do

tblNewCust.addnew
tblNewCust.Cus_no=!CUS_NO
tblNewCust.NewCustFlag=True
tblNewCust.update <===== An error will be trapped here
'if the cust is already in the table

.movenext
Loop until .eof
end with

.movefirst
with tblNewCust

Do
if .NewCustFlag then
'send the email
'now they're and old customer so flag em
!NewCustFlag=False
.Update
endif


Loop
end with
Exit Function

'******
Err_h: 'the trap lands it here. which cancels the update to the flag
'******
If Err = -2147217887 Then 'duplicate key
tblNewCust.cancelupdates
resume next

End If
End Function

 
One error:

.movefirst
with tblNewCust

should be

with tblNewCust
.movefirst
 
A pure Flexibility solution to this would be to add the following code to the Flexibility Project for the Accounts Receivable Customer Maintenance (ARCUSMNT) Screenset.

Code:
Private Sub macForm_Save(AllowSave As Boolean)
  If macForm.mode = Add Then
    ' Insert code to send email here
  End If
End Sub

It is typically best to send automated emails from a central location. Programmatically generated emails usually require piggy-backing on top of the user's email account. If you try to do this through Outlook you may have problems with new Outlook Security patches that may require the user to confirm the use of Outlook by a third-party application (your application). Also, the record of all emails sent stays with the original sender.

I would suggest that you do something along the lines of creating a record in a database table that an application monitors for new records, then emails the new customer notification, and finally marks the record as having been sent.

This is basically a variant on what vbajock suggested earlier. The only difference is that the method I have suggested is more real time and vbajock's is user initiated.

I should also mention that Macola Event Manager works wonders for this type of thing. SQL Notification Services also works well for custom application development. If you were to use SQL Notification Services you could cut out the secondary table and the Flexibility.

Scott Travis
NEXO Systems, Inc.
 
Actually, the code I posted is used in a server based job that isn't actually a Flex app. The program fires off a timer in the middle of the night and sends all kinds of emails all over the place. When the users arrive in the morning they have reports waiting for them in their Outlook inbox, sales reports, negative inventory reports, order reports, and new customer reports, you name it. Its one of my most popular custom apps. Flex-based Outlook apps are, as stravis pointed out, problematic. Pushing that fat memory hog from within the Flex client doesn't work well on particular machines, and the security problems cause the necessity of making code changes all the time. You can get around the security warnings if you are using Exchange, but it is a pain. If you push the emails from the server or from a dedicated PC, you can use Exchange or SMTP to send the emails, or you can use an Outlook client on specifically set up for the job.
 

It has been mentioned before but another option would be to use Event Manager to do this sort of work for you, especially if you don't have access to programming talent or don't have the time.

I have read that with VB you can get around the Outlook Security Warnings by creating and coding a COM add in to Outlook to handle this also. I haven't explored this as an option though.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top