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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Ivan Ficko Profile Picture
    1,380 on at

    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();


  • Community Member Profile Picture
    on at

    Hi Ficko,

    in provided code  

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

    Venkat

  • Suggested answer
    Ivan Ficko Profile Picture
    1,380 on at

    Yes, this value is GUID of your entity.

  • Suggested answer
    Community Member Profile Picture
    on at

    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

  • Community Member Profile Picture
    on at

    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
    on at

    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

  • TomSmelser Profile Picture
    1,570 on at

    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
    SavvyLuke Profile Picture
    655 on at

    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");


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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans