The feed user import module is great.
It is a solution to many real world usage scenarios.

However I cam over a critical limitation, that is, explained in this scenario:

we have 100 users
we have 10 Roles
we have 13 Profile Fields (Division, Department ... etc.)

Goal, is to import users(employee list) from HRMS Payroll Tables into Drupal.

Using Feeds, I have the option to "Update" Existing Drupal Users. this work fine

Except that .... (the Role Mapping should not be disturbed)

On the other side, If I would disable "Update and Replace Existing Users, I would not be able to update the Recent Changes in user Profile. (e.g. an employee has transfered from Sales to Marketing).

Thanks and best regards.

I have marked as "Major" usability issue.

CommentFileSizeAuthor
#4 preserve_roles.patch1.76 KBanschauung
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bakr’s picture

For the time being, I am creating an external middleware scripts that shall do the needy as follows:

1) Set Daily Schedule of Feed User Import ==> Pointing to a Middleware Script that Dynamically Generates CSV content.
2) The above mentioned script, is triggered by the feeds schedule.
3) In turn, it also calls an external routine, that interacts directly with Drupal Profle tables and the external HRMS tables, and shall synch the appropriate fields.

As known to all, the above is not a clean solution, it would be more worthy to have the flexibility within the Feeds USer Import module itself to skip role clearing upon import with "Replace Existing" is enabled.

Best Regards

bakr’s picture

Title: Import and Update User "WithOut" distirbing exisitng roles mapping of local users » Import and Update User "WithOut" disturbing exisitng roles mapping of local users
bakr’s picture

Title: Import and Update User "WithOut" disturbing exisitng roles mapping of local users » Import and Update User "WithOut" disturbing existing roles mapping of local users
anschauung’s picture

FileSize
1.76 KB

I've attached a patch that accomplishes this by adding a "Preserve existing roles" control in the user processor page.

This works well in the few simple tests I've run. But, it involves an extra call to user_load for each matched account. So, you might see performance problems on batches with a large number of replacements.

Please let me know if it works for everyone.

bakr’s picture

Wow, this is very great.

I have applied the patch, seems working from initial testing.

By the help of the spirit of the open-source community, drupal platform is modularly rocking.

Very Big thanks for Davin Hattaway :) :)

anschauung’s picture

Glad it worked out, Bakr :)

ShaunDychko’s picture

Status: Active » Reviewed & tested by the community

This works great!

Dave Reid’s picture

Title: Import and Update User "WithOut" disturbing existing roles mapping of local users » Allow user roles for updated user accounts to be preserved
Version: 6.x-1.x-dev » 7.x-2.x-dev
Status: Reviewed & tested by the community » Needs work

Patch has trailing spaces and indentation errors. Also, we should probably use #states to hide that checkbox if the 'Update existing users' is not enabled.

This could also use a test to ensure it works properly.

Also needs to be applied to 7.x-1.x first, then backported.

MegaChriz’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

I think this is no longer an issue. When you select no additional roles at all and choose to update existing users, the user roles are not touched. If you choose to replace existing users, then the roles that are not selected will be revoked (there currently is a bug when using the "replace users" option, see #1894542: User import does not replace roles with "Additional roles" when replacing existing users).