Skip to content

Conversation

@Chucheen
Copy link

For a multi_select custom_field type, amoCRM demands to be a direct array

[
   "id"=>692250,       //field id
   "values"=> [1662884,1662886]    //Field of multiselect type (an array of values is allowed)
],

instead of

[
  "id"=>691606,       //field id
  "values"=> [
    [
      "value"=>1519210  //Field of list type, enum parameter value is assigned to the field value
    ]
  ]
]

The multi select fields were not being stored from the beginning or when updated. This commit changes the way it's sent and fixes that

For a multi_select field type, amoCRM demands to be a direct array instead of a values: { [value: '1']}.
This commit fixes the way it's sent
@Chucheen
Copy link
Author

Apparently Travis failed because of resolving or installing some dependencies

prop_id = props.send(k).id
prop_val = { value: send(k) }.merge(v)
custom_fields << { id: prop_id, values: [prop_val] }
prop_val = props.send(k)['type_id'] == "5" ? [send(k)] : { value: send(k) }.merge(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is "5" ? Can you explain ? I think you can use constant for that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to use a constant instead. It's the field id for a multiselect type of field.
https://developers.amocrm.com/rest_api/accounts_current.php#type_id

@palkan
Copy link
Contributor

palkan commented Oct 1, 2017

@ivanovaleksey Could you, please, take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants