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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to iterate through entity record using javascripts.

(0) ShareShare
ReportReport
Posted on by 6

can any one give me any sample for crm 2016 for iterating through entity record and check value of the field for the given hardcore value.

e.g.fetch a contact entity record and want to check if lastname is equal to "CONSUMER".

for an example i want the above one , 

Ones i get it will apply the same logic in the for actual reason.

*This post is locked for comments

I have the same question (0)
  • MNarmeen Profile Picture
    1,848 on at
    RE: How to iterate through entity record using javascripts.

    You have to do it via plugin.

    alisharifiblog.wordpress.com/.../retrieve-multiple-records-with-xrmservicetoolkit

  • EmployeeOcta Profile Picture
    6 on at
    RE: How to iterate through entity record using javascripts.

    var Opportunity = Utilities.queryMultipleEntities(oDataSelect);

      if(Opportunity != null && Opportunity.length !=0 )

      {

       if(Opportunity[0].StateCode.Value == 1   )

    {

                             //doing some work here.

                            }

    .Value   is not supported in crm 2016 , how can resolve this.

  • Suggested answer
    MNarmeen Profile Picture
    1,848 on at
    RE: How to iterate through entity record using javascripts.

    getValue();  is used in javascript

  • EmployeeOcta Profile Picture
    6 on at
    RE: How to iterate through entity record using javascripts.

    Hello MN,

    can you replace this line of code

    if(Opportunity[0].StateCode.Value == 1   )

    from above .

    show me how to do that.

  • MNarmeen Profile Picture
    1,848 on at
    RE: How to iterate through entity record using javascripts.

    are you doing this in javascript?

  • Suggested answer
    Sravan Kumar Chandhavolu Profile Picture
    140 on at
    RE: How to iterate through entity record using javascripts.

    Start with simple. Try executing this code in console window of ie, by opening the desired record. This is essentially nothing but iterating all the form data attributes and checking to find if any field's value is "CONSUMER". Fetching the record is another part.

    Xrm.Page.data.entity.attributes.get(function(attribute,index){

                          if(attribute.getValue()=="CONSUMER"){alert("found");}

    })

    If it solved, please mark the answer as verified.

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at
    RE: How to iterate through entity record using javascripts.

    Hi

    My understanding from your code (Utilities.queryMultipleEntities) is that you are using opusUtilities library.

    If it is so, this library uses Organization data service (OData v2 REST endpoint), which is deprecated now, and JQuery.

    You do not need to change this code from .Value, as long as it works fine. Because this is how you would be able to retrieve the value for the attribute of the records returned from this library function.

    If you want to use different library (for Web API) instead of Opus, you can do so, accordingly.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: How to iterate through entity record using javascripts.

    You can try this approach with fetchxml and web api via javascript as shown in the below link

    www.hbs.net/.../using-fetchxml-in-web-api-queries-via-javascript-f

  • EmployeeOcta Profile Picture
    6 on at
    RE: How to iterate through entity record using javascripts.

    Hello Guys,

    if i use below code then what will happen.

    var Opportunity = Utilities.queryMultipleEntities(oDataSelect);

     if(Opportunity != null && Opportunity.length !=0 )

     {

      if(Xrm.Page.getAttribute(Opportunity[0].StateCode).getSelectedOption().value; == 1   )

                          {

                            //doing some work here.

                           }

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans