Not able to map user to opportunity through API


(Lennart van der Garde) #1

Hello all,

I’ve looked through all questions, but couldn’t find an answer to my problem.

I am able to add an opportunity with the following properties:

  • opportunity_title
  • stage (id)
  • opportunity_notes
  • contact (id)

However, I am not able to map a user. I know the ID of the user, but the created opportunity always defaults to the User with ID ‘1’. When I create an opportunity through the API with User id ‘0’ (zero), then no user is attached to the opportunity.

When I create an opportunity with userid ‘26’, which is the ID of the user I want to map the opportunity to, the user on the opportunity is userid ‘1’. I can manually select the User with ID 26 when I’ve created the opportunity, so the user has rights to be assigned to opportunities.

If anyone has some knowledge that could point me in the right direction, I would greatly appreciate that.

Below the JSON that I send with the API:
{
“opportunity_title”:“Quote Request #Q10.84”,
“stage”:{“id”:“8”},
“opportunity_notes”:“1 x (msj006c-Red-L) Plaid Cotton Shirt-Red-L \n1 x (msj006c-Royal Blue-M) Plaid Cotton Shirt-Royal Blue-M \n”,
“contact”:{“id”:“32”},
“user”:{“id”:“26”}
}

Thanks in advance!


(Carlos Ochoa) #2

Hi @Lennart_van_der_Gar1 it looks like we currently map the opportunity assigned user to the user that made the api call. I have filed a ticket with out Product Manager to discuss this issue.


(John Borelli) #3

So you probably already are aware but it’s a common mistake so I’m going to ask anyway…The user id ‘26’ is NOT a contact id for the user in question but rather the actual USER’s id, correct?


(Lennart van der Garde) #4

Thank you for your answers.

I used the userId that I can find when I navigate to Admin->Users.
41

That Id is also used in the dropdown html on every opportunity overview page.


(Lennart van der Garde) #5

Hello all,

I’ve found the reason for the problem. Our api updates the opportunity without specifying the userId. The old value gets probably overwritten.

I am sorry to have waisted your time. This thread can be closed


(Lennart van der Garde) #6

Ok, truth might be in the middle.

If I create an opportunity with the API, the opportunity is assigned to the user that made the API call, as Carlos already said. It ignores the user information that I send with the API.

If I update (patch) an existing opportunity, I can alter the user on that opportunity.

Would still be nice to know if it will ever be possible to be able to set a user when creating the opportunity.


(Simon Rupp-Greene) #7

Hello, just ran into a similar issue. I see that it’s a “limitation” of the api/on purpose, but was hoping to +1 this as a feature request. We can deal with it right now just by updating the opportunity right after creating, but it’d be nice if we could avoid that extra call.


(John Borelli) #8

@Simon_Rupp-Greene,

Have you tried setting the opportunity (with specific UserID) using XML-RPC? I seem to recall a direct table write to create the opp as a working solution.


(Jared Goetz) #9

Hi,
it seems that it’s still impossible create an opportunity with a proper user assigned in one pass. @Carlos_Ochoa what’s the status of this issue? Is seems that it’s already 10 month old, any update?

Furthermore, it seems that now we can’t even change the user Id for existing opportunities, code like

            $opportunity->setAttribute('user', [
                'id' => 12345
            ]);

has no effect.
Surprisingly, it was possible in older versions of PHP SDK, but not now