Documentation

crm.company.userfield.add

Scope: catalog Permissions to execute: for all

crm.company.userfield.add(fields)

Creates a new user field for companies.

System limitation for field name - 20 characters. Prefix UF_CRM_ is always added to the name of the user field. As a result, the actual name length - 13 characters.

Parameters

Parameter Description
fields Set of fields - is an array ("field"=>"value"[, ...]), containing description of user field.
LIST Contains set of list values for additional custom List fields. Indicated when creating/updating a field. Each value is an array with fields:
  • VALUE - list item value. Field is required when a new item is created.
  • SORT - sorting.
  • DEF - when set as Y, then list item is a default value. Multiple field can have several DEF=Y. For a single value field, first item is deemed as default.
  • XML_ID - value external ID. Parameter is used only when updating already existing list item values.
  • ID - value identifier. If specified, it's deemed as an update for existing list item value and not creation of a new one. Useful only when calling methods *.userfield.update.
  • DEL - when set as Y, existing list item will be deleted. Applied when ID parameter is specified.

Full description of fields can be retuned by calling crm.userfield.fields method.

Example #1

BX24.callMethod(
	"crm.company.userfield.add", 
	{
		fields: 
		{
			"FIELD_NAME": "MY_STRING",
			"EDIT_FORM_LABEL": "My string",
			"LIST_COLUMN_LABEL": "My string",
			"USER_TYPE_ID": "string",
			"XML_ID": "MY_STRING",
			"SETTINGS": { "DEFAULT_VALUE": "Hello, world!" }
		}
	}, 
	function(result) 
	{
		if(result.error())
			console.error(result.error());
		else
			console.dir(result.data());
	}
);

Example #2

BX24.callMethod(
	"crm.company.userfield.add", 
	{
		fields: 
		{
			"FIELD_NAME": "MY_LIST",
			"EDIT_FORM_LABEL": "My list",
			"LIST_COLUMN_LABEL": "My list",
			"USER_TYPE_ID": "enumeration",
			"LIST": [ { "VALUE": "Element #1" }, { "VALUE": "Element #2" }, { "VALUE": "Element #3" }, { "VALUE": "Element #4" }, { "VALUE": "Element #5" } ],
			"XML_ID": "MY_LIST",
			"SETTINGS": { "LIST_HEIGHT": 3 }
		}
	}, 
	function(result) 
	{
		if(result.error())
			console.error(result.error());
		else
			console.dir(result.data());
	}
);	


© «Bitrix24», 2001-2024