Reply
Contributor
KevinGreen24
Posts: 7

Can an OpportunityContactRole be created with no Role chosen?

I am running a query to get the opportunity contact roles for an opportunity:
 

Select o.ContactId, o.Contact.FirstName, o.Contact.LastName, o.Role, o.IsPrimary from OpportunityContactRole o Where o.OpportunityId=someid

 

And some of our customers are having problems when this query is run. Is it possible that an opportunity contact role can be set without a role choen? It's not possible in my development instance but is it possible in other types?
 
Thanks.
Super Contributor
werewolf
Posts: 3,520

Re: Can an OpportunityContactRole be created with no Role chosen?

Well what problems are they having exactly?  That query in itself is pretty innocuous.  Is there some error that the query is giving you, or are you finding that the role is null?  In the docs Role is listed as nillable so it can in fact be null.
Contributor
KevinGreen24
Posts: 7

Re: Can an OpportunityContactRole be created with no Role chosen?

Thanks for responding werewolf,

Yeah it's not the query that's the problem, it's when i'm trying to parse out the results and looking for the Role and it doesn't exist in the "Any" structure. For my own testing purposes i'm trying to add a contact to my opportunity with a "blank" or "null" role like you said, and i'm wondering how to do that.

Super Contributor
werewolf
Posts: 3,520

Re: Can an OpportunityContactRole be created with no Role chosen?

Maybe try inserting one via the API?
Contributor
KevinGreen24
Posts: 7

Re: Can an OpportunityContactRole be created with no Role chosen?

That did the trick, thanks. I used the api to create an OpportunityContactRole without a role.

I found out that our customer got in that situation because they did a data migration which left some of their opp contacts without roles.

Appreciated, thanks.

-KG