Selectors 


 

All of the xrmJS selectors works in the same logic.The selector consists of two parts. 
First control type , second control name . Like this ;

_("controlType:controlName")

 

Field Selectors

Field selectors are "field" and "f" You can achieve the field helpers with this selectors.

  • 1.Long syntax
    _("field:new_fieldname")
  • 2.Short syntax
    _("f:new_fieldname")

Lookup Selectors

Lookup selectors are "lookup" and "l" You can achieve the lookup helpers with this selectors.

  • 1.Long syntax
    _("lookup:new_lookupname")
  • 2.Short syntax
    _("l:new_lookupname")

Option Set Selectors 

Option set selectors are "optionset" and "o" You can achieve the option set helpers with this selectors.

  • 1.Long syntax
    _("optionset:new_optionsetname")
  • 2.Short syntax
    _("o:new_optionsetname")

Iframe Selectors

Iframe selectors are "iframe" and "i" You can achieve the iframe helpers with this selectors.

  • 1.Long syntax
    _("iframe:IFRAME_name")
  • 2.Short syntax
    _("i:IFRAME_name")

Section Selectors

Section selectors are "section" and "s" You can achieve the section helpers with this selectors.

  • 1.Long syntax
    _("section:sectionname")
  • 2.Short syntax
    _("s:sectionname")

Tab Selectors

There is two key for select lookup control."lookup" and "l"

  • 1.Long syntax
    _("lookup:new_lookupname")
  • 2.Short syntax
    _("l:new_lookupname")

 

General  Methods


 

You can use general methods  without selector. 

 

entityName()

Returns entity name of entity for the current record.

example:

var entityName = _.entityName();

 

recordId()

Returns the current record id.

example:

var id = _.recordId();

 

formType()

Returns current form type as numeric.Such as : 1 = CREATE , 2= UPDATE ...

example:

var formType = _.formType();

 

userId()

Returns logged user id.

example:

var userId = _.userId();

 

clientUrl()

Returns the base url.

example:

var url = _.clientUrl();

 

orgName()

Returns the current organization name.

example:

var organizationName = _.orgName();

 

Common Methods 


 

This library includes helper for Single Line of Text ,MultiLine , DateTime s



clear() 

Clear the control value.


clear() example:

_("field:new_field").clear();
_("lookup:new_lookup").clear();
_("optionset:new_optionset").clear();

or

_("f:new_field").clear();
_("l:new_lookup").clear();
_("o:new_optionset").clear();
 

hide() 

Hide the control from MS CRM form.

 

hide() example

_("field:new_field").hide();
_("lookup:new_lookup").hide();
_("optionset:new_optionset").hide();
_("section:section_name").hide();
_("iframe:IFRAME_name").hide();
_("tab:tab_name").hide();

or

_("f:new_field").hide();
_("l:new_lookup").hide();
_("o:new_optionset").hide();
_("s:section_name").hide();
_("i:IFRAME_name").hide();
_("t:tab_name").hide();


show() 

Show the field on MS CRM form.


show() example:

_("field:new_field").show();
_("lookup:new_lookup").show();
_("optionset:new_optionset").show();
_("section:section_name").show();
_("iframe:IFRAME_name").show();
_("tab:tab_name").show();

or

_("f:new_field").show();
_("l:new_lookup").show();
_("o:new_optionset").show();
_("s:section_name").show();
_("i:IFRAME_name").show();
_("t:tab_name").show();


disabled() 

Disabled the control from MS CRM form.

 

disable() example:

_("field:new_field").disabled();
_("lookup:new_lookup").disabled();
_("optionset:new_optionset").disabled();

or

_("f:new_field").disabled();
_("l:new_lookup").disabled();
_("o:new_optionset").disabled();


enabled() 

Enabled the control from MS CRM form.

 

enabled() example:

_("field:new_field").enabled();
_("lookup:new_lookup").enabled();
_("optionset:new_optionset").enabled();

or

_("f:new_field").enabled();
_("l:new_lookup").enabled();
_("o:new_optionset").enabled();


isEnable() 

Get enable/disable status from control.


isEnable example:

_("field:new_field").isEnable();
_("lookup:new_lookup").isEnable();
_("optionset:new_optionset").isEnable();

or

_("f:new_field").isEnable();
_("l:new_lookup").isEnable();
_("o:new_optionset").isEnable();


required() 

Set control required ,non-required or recommended.


  • Parameters
  • param
    bool (required)  

    If you want set required , param must be "true" , 
    you want set non-required , param must be "false" .

     

required() examples:

Set required.

_("field:new_field").required(true);
_("lookup:new_lookup").required(true);
_("optionset:new_optionset").required(true);

Set non-required.

_("f:new_field").required(false);
_("l:new_lookup").required(false);
_("o:new_optionset").required(false);


label() 

Get or set control label(Standart,Lookup,Section,Tab,Iframe);


  • Parameters
  • param
    string (optional)  

    If you want get the label of control , param must be not assigned value , 
    you want set the label of control , param must be "text" ,

 

label() examples:

Get label.

var label = _("f:new_field").label();
var label = _("l:new_lookup").label();
var label = _("o:new_optionset").label();
var label = _("s:section_name").label();
var label = _("t:tab_name").label();
var label = _("i:IFRAME_name").label();

Set label.

_("f:new_field").label("test");
_("l:new_lookup").label("test");
_("o:new_optionset").label("test");
_("s:section_name").label("test");
_("t:tab_name").label("test");
_("i:IFRAME_name").label("test");


val() 

Get or set the control value.
Use of val methods are different for field controls(single line of text , multi line , date time) and lookup.


  • Parameters
  • param
    string or array (optional)  If you want get value of control , not assign value to parameter. 

    for field , parameter must be "string" , 
    for lookup , parameter must be "array".Like this;

    {entityType:"Account" , name:"Foo" , id:"0000-0000"}

     

val() examples:

  • for field ;
    _("f:new_field").val();
  • for lookup ;
       val method of lookup returned three value. 

    • entityName
    • name
    • id

     

    var lookupValue = _("l:new_lookup").val();

    var entityType= lookupValue.entityName;
    var name = lookupValue.name;
    var id =lookupValue.id;

set value of control


  • for field ;
    _("f:new_field").val("Hello!");
  • for lookup ;

     _("l:new_lookup").val({entityType:"Contact" , name:"Foo" , id:"0000-0000"});

 

Custom Optionset Methods 


 

labels() 

labels() example

_("o:new_optionset").labels();

Return value


[0] :"label1"
[1] :"label2"
[3] :"label3"


values() 

values() example

_("o:new_optionset").values();

Return value


[0] :"value1"
[1] :"value2"
[3] :"value3"

selected() 

selected() example

var selectedOption = _("o:new_optionset").selected();

Return value


selectedOption.text;
selectedOption.value;

options() 

Returns all options of optionset control as {text:"",value:""} array.

 

options() example

_("o:new_optionset").options();

Return value


[0] :{text:"option1",value:1}
[1] :{text:"option2",value:2}
[3] :{text:"option3",value:3}


addOption() 

Add option to optionset control. 

  • Parameters
  • option
    array (required)  New option value as array like this :
    {text:"New option",value:"10"} 
    index
    int (required)  Position of the new option.

addOption() examples:

  • _("o:new_optionset").addOption({text:"New Option",value:"35"},1);


removeOption() 

Remove option from the optionset control.

  • Parameters
  • index
    int (required)  option index.

removeOption() examples:

  • _("o:new_optionset").removeOption(1);

getOption() 

Return option from optionset control as array.like this {text:"Option",value:"12"}

  • Parameters
  • index
    int (required)  option index.

getOption() examples:

    • _("o:new_optionset").getOption(1);

Returns value

{text:"Option",value:"1"}

Custom Iframe Methods 


 

clear() 

Set "about:blank" the iframe source .

 

clear() example

_("i:IFRAME_name").clear();


url() 

Get or set iframe url. 

  • Parameters
  • url
    string (optional)  Iframe url.If you want get selected iframe url not assign value to paramter. 

url() examples:

  • _("i:IFRAME_name").url("http://testUrl");

 

Custom Tab Methods 


 

expand() 

Expand the selected tab on MS CRM form.

 

expand() example

_("t:tab_name").expand();


collapse() 

collapse the selected tab on MS CRM form.

 

collapse() example

_("t:tab_name").collapse();


sections() 

Get sections of selected tab.

 

sections() example

_("t:tab_name").sections();

Last edited Apr 21, 2015 at 5:38 PM by onurmenal, version 10