Question : How to set up a process that updates a UserRoleID, generates a password, and sends an email message all at once?

It has taken me a long time to frame this question in a readable way that respects the time of the experts who read it. A shout-out to gdemaria and _agx_ for their patient help with this ongoing project.

My task is, I need to create an approval process that does the following:

1) updates table column "UserRoleID" (datatype int) from  value 7 (unapproved) to value 5 (approved)
2) updates another table column "PrincipalApproved" (datatype bit) from 0 to 1 (false to true)
3) generates a random password that gets placed in column UserPassword (see note below)
4) generates an email message that gets sent to the approved UserID, using the previously entered UserEmail, that contains a) a brief welcome message and b) the generated password from step 3, above

The Approve button (or link) will appear in a list of users who have UserRoleID = 7. The template on which the approve button will appear is userList.cfm?UserRoleID=7. This page simply requests a list of Unapproved Principals (UserRoleID = 7).

My thought is, I can put all of these four approval functions in a new template: approve_template.cfm.

When an administrator clicks on a link to approve_template.cfm, the above four actions are processed.

(Should this "Approve" be a form submit button, so that I can set up a form action, like form.doApprove, which processes when the administrator clicks the Approve submit button?)

Regarding the generation of a password, _agx_ suggested this UDF Source:

http://www.cflib.org/udf/MakePassword

... with which I've been experimenting.

I'll start with this opening question. For starters I am seeking a good plan. Do I have a good plan? I have been thinking about this task for several days. Thank you for any advice.

Eric

p.s. I have some beginning ideas for the approve_template.cfm that I will post soon.
Attachments:
 
"Approve this Principal" link at far right of table of users
"Approve this Principal" link at far right of table of users
 

Answer : How to set up a process that updates a UserRoleID, generates a password, and sends an email message all at once?

Hey Eric, a few observations..

This statement:  
     <cfif url.UserRoleID IS 3 or 1>

is not the same as

    <cfif url.UserRoleID IS 3 or  url.UserRoleID IS 1>

This statement will alway be entered, because the second criteria, which is simply "1" will always true

    <cfif url.UserRoleID IS 3 or 1>
                                             ^^^  this is like saying  "or  TRUE"   which is always true, like  1 = 1

   So this CFIF will always be entered.

Random Solutions  
 
programming4us programming4us