CodeCharge StudioRetrieves the primary key value that uniquely identifies the currently logged in user.
CCGetUserID()
This code would usually be placed in the Before Show event of a Record form.
If tasks.EditMode Then
tasks.user_id_assign_by.Value = CCDLookUp("emp_name", "employees", "emp_id=" &_
DBIntranetDB.ToSQL(tasks.user_id_assign_by.Value, ccsInteger), DBIntranetDB)
Else
tasks.user_id_assign_by.Value = CCDLookUp("emp_name", "employees", "emp_id=" &_
DBIntranetDB.ToSQL(CCGetUserID(), ccsInteger), DBIntranetDB)
End if
The following code uses the CCGetUserID function to lookup the current user's name and email address which is then used for sending an email using the ASPEmail component.
This code would usually be placed in the After Insert event of a Record form.
Dim Mailer
Set Mailer = Server.CreateObject("Persits.MailSender")
Mailer.From = CCDLookUp("email", "employees", "emp_id=" &_
DBIntranetDB.ToSQL(CCGetUserID(), ccsInteger), DBIntranetDB)
Mailer.FromName = CCDLookUp("emp_name", "employees", "emp_id=" &_
DBIntranetDB.ToSQL(CCGetUserID(), ccsInteger), DBIntranetDB)
Mailer.AddAddress = CCDLookUp("email", "employees", "emp_id=" &_
DBIntranetDB.ToSQL(tasks.user_id_assign_to.Value, ccsInteger) , DBIntranetDB)
Mailer.Host = "mysmtphost.com"
Mailer.IsHTML = True
Mailer.Subject = "New task for you"
Mailer.Body = "A new task was assigned to you. "
Mailer.Send
set Mailer = Nothing