locked
Enumerate "Result" picklists RRS feed

  • Question

  • I'm looking for an OnSave event that can loop through an entire record and count all the fields labeled Result and a picklist value of id 2(Incorrect)

     

    I could certainly write a function for the OnLoad and call it during the Onchange of each result fields, but there is over 40 of these.  But that would be a PIA.

     


    Withers *Check out my javascript working examples on my blog http://withersblog.withersdavid.com/
    Wednesday, July 28, 2010 11:24 PM

Answers

  • You could use jQuery to achieve something like that.  You'd need to load the jQuery library, but then you can target similarly attributed objects and iterate over them.

    Something like:

    $("tagName[attribute~='value']").each(function (index) {
     doStuff(this);
    });
    
    where you'll have to figure out <tagName><attribute><value> by using the IE developer tools or similar.  You can also write more complex queries (the bit within the $("")) to target child objects of located container objects; thus the picklist within a span containing your given label.
    --pogo (pat)
    Thursday, July 29, 2010 2:28 AM

All replies

  • You could use jQuery to achieve something like that.  You'd need to load the jQuery library, but then you can target similarly attributed objects and iterate over them.

    Something like:

    $("tagName[attribute~='value']").each(function (index) {
     doStuff(this);
    });
    
    where you'll have to figure out <tagName><attribute><value> by using the IE developer tools or similar.  You can also write more complex queries (the bit within the $("")) to target child objects of located container objects; thus the picklist within a span containing your given label.
    --pogo (pat)
    Thursday, July 29, 2010 2:28 AM
  • Hi David,

    I have tested the code on CRM 4.0 with the following script in the account's OnLoad event:

    var text = "";
    var count = 0;

    for (var index in crmForm.all) {
        var control = crmForm.all[index];

        if (control.req && (control.Disabled != null)) {
            text += control.id + ",";
            count++;
        }
    }

    alert(count + " Fields: " + text);

     

    Hope this helps.


    Thanks, Ranjitsingh R | http://mscrm-developer.blogspot.com/ | MS CRM Consultant
    • Proposed as answer by Ranjitsingh R Tuesday, August 3, 2010 5:58 AM
    Thursday, July 29, 2010 4:41 AM
  • Ranj,

    All that does is count all the fields in the form and list them.

    I'm going to investigate Pogo's idea or just use excel to make the commands quickly and paste them all.

    Thanks everyone for their replies!


    Withers *Check out my javascript working examples on my blog http://withersblog.withersdavid.com/
    Thursday, July 29, 2010 3:18 PM