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

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
}