If you need to use a field other than "id" to update/create user information within Feedback, there are two more parameters that may be added to the snippet:
Key: settings.user.find_by
Required?: Optional
Description: Specifies which user field should be used to find/create a user within Feedback. Valid values are "email" and "id". Defaults to "id"
Example: "email" or "id"
Note: If using "email", the user ID must be unique within the account. For example, you could have a user with #111 in an account named "Test One", AND have a user with #111 in "Test Two". But you couldn't have two users with the same #111 in "Test One".
Key: settings.account.find_by
Required?: Optional
Description: Specifies which account field should be used to find/create an account within Feedback. Valid values are "name" and "id". Defaults to "id"
Example: "name" or "id"
For example:
<script> | |
var receptiveAppSettings = { | |
"return_url":"http://example.com/user/123", | |
"settings": { | |
"user": { | |
"find_by": "email" | |
}, | |
"account": { | |
"find_by": "name" | |
} | |
}, | |
"account":{ | |
"id":"321", | |
"name":"Company Ltd", | |
"monthly_value":"99.99", | |
"is_paying":"true"}, | |
"vendor":{ | |
"id":"01234567-89ab-...."}, | |
"user":{ | |
"id":"123", | |
"email":"joe@example.com", | |
"full_name":"Joe Bloggs", | |
"allowed_products":[{"name": 'MyProduct', "id":'my_product_external_id'}] | |
} | |
}; | |
</script> |
With this in place, users/accounts are looked up in Feedback by the field specified. Please note, that if anything other than "id" is used:
- The ID specified in the snippet will overwrite the current ID within Feedback
- If two or more records exist with the same field data, the operation will fail with a 400 code