Forum .LRN Q&A: Re: Bulk User Account problem

Collapse
Posted by Matthew Coupe on
Hello,

Ok, I've added in some ns_log notices to see what's going on. The info is being printed out from the first 5 notices and it reading from the csv files I prepared, however, concerningly the 'ns_log "It has gotten past the required data check"' part does not appear in the error log at all and by my reckoning it should. Would you agree?

Matthew

db_transaction {

oacs_util::csv_foreach -file $file_location -array_name row {

ns_log notice "it is reading the file"
ns_log notice $row(email)
ns_log notice $row(first_names)
ns_log notice $row(last_name)
ns_log notice $row(username)

# First make sure the required data is there
if { ![info exists row(email)] || ![info exists row(first_names)] || ![info exists row(last_name) || ![info exists row(username)]] } {
doc_body_append "
Datafile must include at least the email, first_names, last_name, username fields
"
db_abort_transaction
return
}

ns_log notice "it has gotten past the required data check"

# We need to insert the ACS user
if {![info exists row(password)]} {

# We need to insert the ACS user
set password [ad_generate_random_string]
} else {

set password $row(password)
}
.
.
.
.

Collapse
Posted by Matthew Coupe on
FIXED IT!!

OK, there is a bug in the code which was stopping it from working. The square brackets after [info exists row(last_name) are missing and there are 2 closing square brackets after ![info exists row(username)]] and so I closed them both off with 1 bracket and the upload went through and I was able to add the users to groups.

If someone could check this out then perhaps it should be patched or something? I haven't done that before and so I don't know how it works.

Regards,
Matthew

Original code:

oacs_util::csv_foreach -file $file_location -array_name row {

# First make sure the required data is there
if { ![info exists row(email)] || ![info exists row(first_names)] || ![info exists row(last_name) || ![info exists row(username)]] } {
doc_body_append "
Datafile must include at least the email, first_names, last_name, username fields
"
db_abort_transaction
return
}

Changed code:

oacs_util::csv_foreach -file $file_location -array_name row {

# First make sure the required data is there
if { ![info exists row(email)] || ![info exists row(first_names)] || ![info exists row(last_name)] || ![info exists row(username)] } {
doc_body_append "
Datafile must include at least the email, first_names, last_name, username fields
"
db_abort_transaction
return
}