2

I have tried setting the parameter as:

array("item1","item2","item3")

and also as:

new array("item1","item2","item3")

and also as:

var Labels = new array("item1","item2","item3")

enter image description here

but I can't seem to pass an array to the following function:

function BoldLabel(Labels) {
  var length = Labels.length;
  var element = null;
  for (var i = 0; i < length; i++) {
    element = Labels[i];
    document.getElementById(element).style.fontWeight="bolder";
    document.getElementById(element).style.fontSize="13px";
  }
}

I keep getting an "array is undefined" error. I thought for sure I saw this done somewhere but can't find the example anymore. The problem is that I'd like to be able to reuse this code and so just passing an array of the items I want to bold would be easier than cutting and pasting the code to a new function and writing in each label name individually like

document.getElementById("new_pricingsubtotal_c").style.fontWeight="bolder";
document.getElementById("new_pricingsubtotal_c").style.fontSize="13px";
document.getElementById("new_pricingsubtotal1_c").style.fontWeight="bolder";
document.getElementById("new_pricingsubtotal1_c").style.fontSize="13px";
document.getElementById("new_lineitemtotal_c").style.fontWeight="bolder";
document.getElementById("new_lineitemtotal_c").style.fontSize="13px";
document.getElementById("new_trucktotalcost_c").style.fontWeight="bolder";
document.getElementById("new_trucktotalcost_c").style.fontSize="13px";

Any help with this would be greatly appreciated!!

5
  • 1
    As a side, you do know this sort of customisation is unsupported and is not guaranteed to work cross browser or in future rollups of CRM. Related: stackoverflow.com/questions/15742740/…
    – James Wood
    Apr 2, 2013 at 16:17
  • I completely understand but Microsoft's kind of forcing our hand here without giving us a way to do it through the Xrm framework. We are an on-premise deployment on UR12 so we'll just go slowly with our updates from here and make sure it doesn't break anything. If it does or has the ability to then we'll have to change the code. I'm hoping they'll implement this ability in the future and then we just amend our code and away we go. Until then, our options are to rewrite the entire form as a web resource using an oData call etc etc just to format anything the way we want. Apr 2, 2013 at 16:23
  • 1
    Sounds like a sensible attitude, its just important to be aware of what future changes may do to your existing work, e.g. have you seen the Polaris forms? They are totally different.
    – James Wood
    Apr 2, 2013 at 17:19
  • I have, but they aren't out in UR12 for On-premise yet. Is there a way to disable that version of forms entirely when it is released, or a list of what incompatibilities arise out of this new form version? Apr 2, 2013 at 17:48
  • Well they have a different layout & style, so its reasonable to expect some HTML changes, also the current versions don't even have JavaScript. In Online you have to opt-in, so might be the same on-premise, once enabled you can just hide the forms using security roles as you can now with a normal form.
    – James Wood
    Apr 2, 2013 at 21:30

1 Answer 1

5

Did you try Array (as opposed to array)? Also, you might try it using an array literal, e.g.: var myarray=["item1", "item2", "item3"]

4
  • ahhh man this whole casing this is killing me. I'm fairly new to JavaScript but really getting into it for this CRM development. Apr 2, 2013 at 16:06
  • Yep... changing to Array() did it. So the lesson for me is, when it says it's undefined... I've probably got the naming wrong either a typo or casing. And what would be the benefit to the second example you provided? Just curious since it seems to work fine as Array("item","item","item") Apr 2, 2013 at 16:10
  • 1
    Glad it helped. No special benefit to using an array literal, just mentioned it as a way to help you debug the issue.
    – udog
    Apr 2, 2013 at 16:12
  • It won't let me without 15 rep. Apr 2, 2013 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.