Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for multi select custom fields when saving #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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