Form is the base object for referencing the tabs, attributes, sections, and left nav items. Use Form.Attributes for Attributes, Form.Tabs for Tabs, Form.Sections for Sections and Form.Navigation for Left Nav Items.
The syntax below is the same for each type but one difference is that Form.Attributes.<fieldname> will give you both Attribute and Control objects whereas the other types will give you only their respective type (Xrm Tab, Section, Nav item object).
Form.Attributes. – This will give you intellisense and show you all the attributes that exist on the form currently
Form.Attributes.<fieldname> - This will give you BOTH the Xrm.Page.getAttribute(‘fieldname’) AND Xrm.Page.getControl(‘fieldname’) objects combined into one object (notice you can use both setValue and setVisible below)
Form.Attributes.<fieldname>.exists() - This will return a boolean telling whether the field exists on the form or not (in case the generated model is out of date)
Form.Attributes.Ids. – This will list the same thing as .Attributes but gives you a reference to the string value of the Id instead of the attribute/control object
How to generate it:
- Edit the provided sample.jsconfig file.
- Update CrmServer to use the correct server and org.
- Set the JsDirectory to be the folder where your script files are located.
- Add an Entity node for the entity form that you will be working on
- EntityName is required and needs to be the schema name
<Entity EntityName="contact" FileName="contact.js" />
An added benefit of using Form.Attributes.<fieldname> is that the first time you call a method on the object, it will cache the respective XRM object behind the scenes to optimize performance.
You can find it here - http://crmjsmodelgenerator.codeplex.com/