Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

how to verify value of a simple text field in My CRM console application

Posted on by Microsoft Employee

now my requirement from customer..
i have bill id from third part system.
i wanted to verify bill id is exist or not in entity(kcd_creditrisk) ,field name(kcd_billingid) as simple test..
please help me .
Venkat

*This post is locked for comments

  • Suggested answer
    SavvyLuke Profile Picture
    SavvyLuke 655 on at
    RE: how to verify value of a simple text field in My CRM console application

    Why not just check using GetAttributeValue after you do your query expression. For example:

    Guid billingId = Guid.Empty;
    //queryexpression stuff here billingId = ec.GetAttributeValue<Guid>("kcd_billingid");


  • TomSmelser Profile Picture
    TomSmelser 1,570 on at
    RE: how to verify value of a simple text field in My CRM console application

    If you are returning multiple records in your query the you want to check each one.

    Something like this would work:

    foreach (Entity rec in ec.Entities)
    {
      if (rec.Contains("kcd_billingid"))
    {
       // value exists
     }
    }

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to verify value of a simple text field in My CRM console application

    Hi venkataramana,

    if you solved the problem thanks to an answer, please mark it as verified to encourage the community to provide more and more a better support. Thank you. Francesco

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to verify value of a simple text field in My CRM console application

    Hi venkataramana,

    if you solved the problem thanks to an answer, please mark it as verified to encourage the community to provide more and more a better support. Thank you. Francesco

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to verify value of a simple text field in My CRM console application

    Hi Venkat,

    happy to help you again :-)

    Please use the following code:

    QueryByAttribute query = new QueryByAttribute("kcd_creditrisk");
    query.ColumnSet = new ColumnSet("createdon");
    query.Attributes.AddRange("kcd_billingid");
    query.Values.AddRange(thebillingidvalue);
    Entity entity = svc.RetrieveMultiple(query).Entities.ToList().FirstOrDefault();
    
    // credit risk found
    if (entity != null)
    {
        // do something
    }
    // credit risk NOT found
    else
    {
        // do something else
    }

    Please let me know.

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Suggested answer
    Ivan Ficko Profile Picture
    Ivan Ficko 1,380 on at
    RE: how to verify value of a simple text field in My CRM console application

    Yes, this value is GUID of your entity.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: how to verify value of a simple text field in My CRM console application

    Hi Ficko,

    in provided code  

       <attribute name='kcd_creditriskid' />----> is it guid id?

    Venkat

  • Suggested answer
    Ivan Ficko Profile Picture
    Ivan Ficko 1,380 on at
    RE: how to verify value of a simple text field in My CRM console application

    You need to write a simple query that retrieves all entities that have kcd_billingid equals to your bill id value.

    var fetchXml=@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
      <entity name='kcd_creditrisk'>
        <attribute name='kcd_creditriskid' />
        <filter type='and'>
          <condition attribute='kcd_billingid' operator='eq' value='<YOUR_BILL_ID_VALUE_HERE>' />
        </filter>
      </entity>
    </fetch>";
    var exists = service.RetrieveMultiple(new FetchExpression(fetchXml)).Entities.Any();


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans