Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Sep 26, 2012 @ 19:59
    Bo Damgaard Mortensen
    0

    Getting a null pointer reference on member import

    Hi all,

    I'm using CMSImport to import members from a webservice which gets updated with new members regularly. I have mapped the fields I need to import and made sure that e-mail and username is unique (in fact, they're both set to the e-mail address) and I have added default values to the other fields in case some of they may be null or empty.

    The scheduler is running every minute as it should, but I keep getting the following error:

    CMSImport: A record failed to import for aliashjemmeside error:System.NullReferenceException: Object reference not set to an instance of an object. at umbraco.cms.businesslogic.member.Member.MakeNew(String Name, String LoginName, String Email, MemberType mbt, User u) at umbraco.cms.businesslogic.member.Member.MakeNew(String Name, MemberType mbt, User u) at CMSImportLibrary.Import.MemberImporter.ImportMembers(ImportState state, User importAsUser, String datasourceFile)

    I have double checked the fields for null values and made sure the field "hjemmeside" is never null. The new member isn't imported when the scheduled import has run. When I run the import manually, it gets imported just fine.

    Does anyone have a clue on what to do about this? :-) Any help/hint is greatly appreciated!

    Thanks in advance,

    Bo

  • Richard Soeteman 4036 posts 12863 karma points MVP
    Sep 27, 2012 @ 07:22
    Richard Soeteman
    0

    Hi Bo,

    It's only the scheduler? I think you need to check if the assigned user still exist. There was also a bug with assigning users but that was solved in 2.2.1.

    Hope this helps,

    Richard

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Sep 27, 2012 @ 11:51
    Bo Damgaard Mortensen
    0

    Hi Richard,

    Thanks for your fast input!

    Yes, the CMSImport scheduler is the only one running. I have checked that the user doesn't exist in the members section before importing and I've checked that it still exists in the XML document I'm trying to import.

    The running version of CMSImport is 2.1.1, so maybe an upgrade could fix it? I should simply copy over the new CMSImport dll file and then it's upgraded? :-)

    The only thing I have "customized" with CMSImport is hooking up on the MemberImport.Imported which fires after the import has run, right?

    The event code is used for setting members who are not found in the XML document to deactivated (bool) and the code looks like this:

    public CMSImportEvents()
            {
                MemberImport.Imported += new MemberImport.ImportedEventHandler(MemberImport_Imported);
            }
    
    
            void MemberImport_Imported(ImportEventArgs e)
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load("urlToXml");
                XmlNodeList emailAdresses = xmlDoc.GetElementsByTagName("AccessUserEmail");
    
                List<string> xmlEmails = new List<string>();
                int i = 0;
                while (i < emailAdresses.Count)
                {
                    xmlEmails.Add(emailAdresses[i].InnerText);
                    i++;
                }
    
                var umbMembers = uQuery.GetMembersByType("Extranet");
    
                foreach (var member in umbMembers)
                {
                    if (!xmlEmails.Contains(member.LoginName))
                    {
                        member.getProperty("deaktiveret").Value = "1";
                        member.Save();
                        Log.Add(LogTypes.Custom, 1329, member.LoginName + " was not found in the XML document and has been deactivated");
                    }            
                }
    
                umbraco.library.RefreshContent();            
            }

    Thanks again.

    All the best,

    Bo

  • Richard Soeteman 4036 posts 12863 karma points MVP
    Sep 28, 2012 @ 09:22
    Richard Soeteman
    0

    HI Bo,

    With the user I mean the user you assigned to trigger the import, not the Member. An upgrade could fix it in that case yes. Just run the installer again and it should be fine. Think that is causing the issue otherwise you would have had the same error when you run the import directly

    Hope this helps,

    Richard

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Sep 28, 2012 @ 13:34
    Bo Damgaard Mortensen
    0

    Hi again Richard,

    I checked that the admin user is still there :-) Also, I've run the installer again which upgraded it to the current version. However, when I click on any of the scheduled imports I get an exception saying: "invalid column 'importAsUser'"

    I tried to set up a scheduled task to run my custom import trigger, but it still gives me the null pointer error unless I run it manually :-/

    Thanks again!

    Bo

  • Richard Soeteman 4036 posts 12863 karma points MVP
    Oct 01, 2012 @ 17:20
    Richard Soeteman
    0

    Hi Bo,

    I think that the Admin user has a different Id than it normally has (not 0). That's why we found the bug teh other day. Run the script below to update the database please. Then open the Scheduled import in Umbraco select the user again and save it please.

     ALTER TABLE dbo.CMSImportScheduledTask ADD
         ImportAsUser int NULL

    Thanks,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft