Monday 15 February 2016

Commerce Server Error : The requested profile could not be retrieved

Leave a Comment
I've been working with Sitecore Commerce 8 powered by Commerce Server now for a while and trying to configure the demo store which is based upon Reference Storefront solution provided by Sitecore commerce product team.  I’ve successfully managed to get the demo store running after following configuration steps however I’d faced few issues while setting it up. In my upcoming blog posts I’ll be sharing my learning on some troubleshooting I went through.

I was trying to create a user account in demo storefront website. I got below error once I clicked on create user button after entering relevant details in create an account form.   
Register: The requested profile could not be retrieved because the key name provided does not exist or is not an indexed property. The profile type is 'UserObject'. The key name provided is ‘GeneralInfo.ExternallD’.
In order to resolve above issue, I did following steps:
  1. Verify that profile schema is correct. If profile schema is incorrect then import profile schema again.
  2. After importing schema, modify Sitecore Commerce 8.0 powered by Commerce Server Profile Schema for Sitecore Integration as described here.
  3. I have found that profile database schema was not correct and u_external_id column was missing in UserObject table of profile database.
  4. Make the following changes in UserObject table of profile database:
    Add column: u_external_id NVARCHAR(256) NOT NULL
    IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'userobject' AND COLUMN_NAME = 'u_external_id')
    BEGIN
     ALTER TABLE dbo.UserObject ADD u_external_id nvarchar(256) NOT NULL
    END
    GO
    
    Create Index on: u_external_id, UNIQUE NONCLUSTERED INDEX and ASC
    IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[UserObject]') AND name = N'IX_UserObject_ExternalId')
     DROP INDEX [IX_UserObject_ExternalId] ON [dbo].[UserObject]
    GO
    
    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[UserObject]') AND name = N'IX_UserObject_ExternalId')
    CREATE UNIQUE NONCLUSTERED INDEX [IX_UserObject_ExternalId] ON [dbo].[UserObject]
    (
     [u_external_id] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    GO
    
  5. Update Sitecore Commerce 8.0 powered by Commerce Server Profile Schema. Add a new GeneralInfo.ExternalId profile property that maps to the external id column, it must be required and unique. This blog explains how to add new property to user object in commerce server profile system.
  6. Refresh the cache and reload the register account page. You should no longer get the above error message and should be able to create new user account in demo storefront website.
Comments and suggestions are most welcome. Happy coding!  

0 comments :

Post a Comment