web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Erro get field custom using c#

(0) ShareShare
ReportReport
Posted on by 694
Dears, good morning,

We are trying to read a custom field prefixed with new in the user table and I am getting the error below.

{"A entidade 'SystemUser' não contém o atributo com Name = 'new_cpf' e NameMapping = 'Logical'.


MetadataCacheDetails: ProviderType = Dynamic, StandardCache = True, IsLoadedInStagedContext = False, Timestamp = 170964232,


MinActiveRowVersion = 170964232, MetadataInstanceId = 23673480, LastUpdated = 2021-07-04 01: 28: 38.383 "}

Has anyone experienced a similar error? Can you help me?

Thanks

  • Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    Hello Ricardo,

    Please make sure you have the correct field name(new_cpf) from the user entity. This is what the error says.

    Also, Please share that retrieving code line here for more info

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Good afternoon Naveen Ganeshe,

    The field is correct with its respective name

    Here's the code we're using.

    public static EntityCollection GetEntitySystemUser(string guidUser)

            {

                var criteria = new FilterExpression();

                criteria.AddCondition("systemuser", "systemuserid", ConditionOperator.Equal, guidUser);

                QueryExpression query = new QueryExpression("systemuser");

                query.ColumnSet = new ColumnSet("new_cpf");

                query.Criteria = criteria;

                return CRMContext.Service.RetrieveMultiple(query);

            }

    A detail is that the field only appears when the value is filled.

    We also use query.ColumnSet = new ColumnSet(true); to bring up all fields, but even so the new custom field didn't come.

    Thanks

  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    Hi Ricardo,

    try this

    public static EntityCollection GetEntitySystemUser(string guidUser)
    
            {
    
                var criteria = new FilterExpression();
    
                criteria.AddCondition("systemuser", "systemuserid", ConditionOperator.Equal, guidUser);
    
                QueryExpression query = new QueryExpression("systemuser");
                
                 var columnNames = new[] { “new_cpf” };
    
                query.ColumnSet = new ColumnSet(columnNames);
    
                query.Criteria = criteria;
    
                return CRMContext.Service.RetrieveMultiple(query);
    
            }

    Hope it will be helpful 

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Hola Naveen,

    Thanks for the feedback, I'll test and let you know if I managed to get the field value

    Tanks

  • Willian Kupas Profile Picture
    10 on at

    Hi Naveen how are you?

    I'm the developer working on this project with Ricardo.

    I tested the plugin with your code but got the same error. The field is properly filled out.

  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    the error is clear: there is no attribute named "new_cpf" inside systemuser entity. If this attribute exists please:

    1) post a screenshot of this attribute inside the entity designer

    2) make sure your connection is against the instance where this attribute is created (maybe you created just in DEV but the connection is against PROD)

    Now, the code of this function public static EntityCollection GetEntitySystemUser(string guidUser)

    if you pass a guidUser (and I assume it's an ID of the entity, you can just do the following:

    public static Entity GetEntitySystemUser(string guidUser) {
    try {
        Guid id = Guid.Parse(guidUser);
        return CRMContext.Service.Retrieve("systemuser", id, new ColumnSet("new_cpf"));
    } catch (Exception ex) {
        string errorMessage = ex.Message;
        return null;
    }
    }

    of  course the above code is based on your code, in other conditions the code should be written in a different way.

  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    Hello Willian,

    Please share the screenshot of your field in CRM and as Guido mentioned, check the connection if it is with the right environment or not. I don't think there is any other issue

  • Willian Kupas Profile Picture
    10 on at

    Hi Guido,

    In fact the entity "system user" did not have the field "new_cpf".

    This field was created in a test environment, and the scenario I was testing was set to production.

    Sorry for the inconvenience, and thanks for the help.

  • Ricardo Rodrigues dos Santos Profile Picture
    694 on at

    Guido and Naveen good afternoon,

    We managed to get the field, the connection string of the homologation base was pointed to the Production base, for this reason the field was not displayed.

    Thanks for the support.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Syed Aqib Raza Profile Picture

Syed Aqib Raza 140

#2
ParthPatel249 Profile Picture

ParthPatel249 92

#3
11manish Profile Picture

11manish 88 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans