locked
Can't get Case Access Permissions to work in CRM 2011 Customer Portal RRS feed

  • Question

  • I've got a new install of the portal and am trying to use the create case functionality.  Whenever I hit the button the page just reloaded.  I debugged it and found that this statement was returning false.

    if

     

    (access == null || !access.Adx_Create.GetValueOrDefault())

     

    When I look at the contact record in CRM it has a case Access Permissions entity associated with it.  Here are the values

    Name: Full

    Account:

    Contact: (My contact)

    Scope: Self

    Create: True

    Read: True

    Delete: true

    Write: True

    I haven't found any documentation that covers this setup in much detail, but this certainly seems to me like the contact should have the ability to use the create case window.

    It should also be noted, that create case is not available on the case menu item.  I had to type in the page name to even be able to get to the page, which I believe means that it's not recognizing my rights to create cases on the other window as well.

    I am logged in with a Live ID and I've verified that it's the correct contact that I'm using.  It lists the contact name in the upper right hand corner when I'm logged in, and if I change the name of the contact in CRM that I'm trying to work with, I see that change reflected on the portal.  (Just giving some background so someone doesn't think it's a dumb mistake of the wrong contact.)

    Would appreciate some help or better yet links to more detailed documentation.  I've thoroughly reviewed the word documents included with the portal.

    Thursday, July 14, 2011 7:11 PM

Answers

  • Do you know if it's the cast to Adx_caseaccess that's failing, or is GetCaseAccessByContact actually returning null?

    Also, does your contact have a parent customer associated with it? The behaviour of GetCaseAccessByContact changes in that case, and adds an additional filter to the query -- it looks for a Case Access record that is associated with both the contact, and that account.

    Here's a code snippet that reproduces the behaviour of GetCaseAccessByContact. If necessary, pasting it into your code and stepping through it in the debugger might reveal the issue.

    public static Entity GetCaseAccessByContact(OrganizationServiceContext context, Entity contact)
    {
     contact.AssertEntityName("contact");
    
     if (contact == null) return null;
    
     var parentCustomerAccount = contact.GetRelatedEntity(context, "contact_customer_accounts");
    
     IEnumerable<Entity> findCaseAccess;
    
     // contact is not associated with a parent account record
     if (parentCustomerAccount == null)
     {
      findCaseAccess =
       from aa in context.CreateQuery("adx_caseaccess").ToList()
       let c = aa.GetRelatedEntity(context, "adx_contact_caseaccess")
       where c != null && c.GetAttributeValue<Guid>("contactid") == contact.GetAttributeValue<Guid>("contactid")
       select aa;
     }
     else
     {
      findCaseAccess =
        from ca in context.CreateQuery("adx_caseaccess").ToList()
        let c = ca.GetRelatedEntity(context, "adx_contact_caseaccess")
        let a = ca.GetRelatedEntity(context, "adx_account_caseaccess")
        where c != null && c.GetAttributeValue<Guid>("contactid") == contact.GetAttributeValue<Guid>("contactid")
         && a != null && a.GetAttributeValue<Guid>("accountid") == parentCustomerAccount.GetAttributeValue<Guid>("accountid")
        select ca;
     }
    
     return findCaseAccess.FirstOrDefault();
    }
    

    Hope that helps.

    • Proposed as answer by Jim Glass Jr Thursday, July 21, 2011 6:42 PM
    • Marked as answer by Palak Kadakia Monday, January 23, 2012 2:45 AM
    Thursday, July 21, 2011 4:39 PM
  • I got the same problem! I didn't resolve it yet. But I noted everytime I change de account in case access and save. The case access in the website was updated. Try it!
    • Marked as answer by Palak Kadakia Monday, January 23, 2012 2:45 AM
    Thursday, November 10, 2011 6:21 PM

All replies

  • I wanted to provide some additional information.  I found that on the create case page the get case access by contact is returning null

    var

     

    access = ServiceContext.GetCaseAccessByContact(Contact) as Adx_caseaccess;

     

    When I test for null

    (access ==

     

    null).ToString()

     

    This comes back as true

     

    Thursday, July 14, 2011 8:39 PM
  • Do you know if it's the cast to Adx_caseaccess that's failing, or is GetCaseAccessByContact actually returning null?

    Also, does your contact have a parent customer associated with it? The behaviour of GetCaseAccessByContact changes in that case, and adds an additional filter to the query -- it looks for a Case Access record that is associated with both the contact, and that account.

    Here's a code snippet that reproduces the behaviour of GetCaseAccessByContact. If necessary, pasting it into your code and stepping through it in the debugger might reveal the issue.

    public static Entity GetCaseAccessByContact(OrganizationServiceContext context, Entity contact)
    {
     contact.AssertEntityName("contact");
    
     if (contact == null) return null;
    
     var parentCustomerAccount = contact.GetRelatedEntity(context, "contact_customer_accounts");
    
     IEnumerable<Entity> findCaseAccess;
    
     // contact is not associated with a parent account record
     if (parentCustomerAccount == null)
     {
      findCaseAccess =
       from aa in context.CreateQuery("adx_caseaccess").ToList()
       let c = aa.GetRelatedEntity(context, "adx_contact_caseaccess")
       where c != null && c.GetAttributeValue<Guid>("contactid") == contact.GetAttributeValue<Guid>("contactid")
       select aa;
     }
     else
     {
      findCaseAccess =
        from ca in context.CreateQuery("adx_caseaccess").ToList()
        let c = ca.GetRelatedEntity(context, "adx_contact_caseaccess")
        let a = ca.GetRelatedEntity(context, "adx_account_caseaccess")
        where c != null && c.GetAttributeValue<Guid>("contactid") == contact.GetAttributeValue<Guid>("contactid")
         && a != null && a.GetAttributeValue<Guid>("accountid") == parentCustomerAccount.GetAttributeValue<Guid>("accountid")
        select ca;
     }
    
     return findCaseAccess.FirstOrDefault();
    }
    

    Hope that helps.

    • Proposed as answer by Jim Glass Jr Thursday, July 21, 2011 6:42 PM
    • Marked as answer by Palak Kadakia Monday, January 23, 2012 2:45 AM
    Thursday, July 21, 2011 4:39 PM
  • I got the same problem! I didn't resolve it yet. But I noted everytime I change de account in case access and save. The case access in the website was updated. Try it!
    • Marked as answer by Palak Kadakia Monday, January 23, 2012 2:45 AM
    Thursday, November 10, 2011 6:21 PM
  • I have the same issue and have debugged it further.

    contact = null

    what would cause this?

    Thursday, November 15, 2012 12:35 PM