AleksandrRogov / DynamicsWebApi

DynamicsWebApi is a Microsoft Dataverse Web API helper library for JavaScript & TypeScript
MIT License
272 stars 60 forks source link

Setting ownerid when creating an entity #99

Closed FlandersBurger closed 3 years ago

FlandersBurger commented 3 years ago

I'm trying to set the [Team] owner of a lead I'm creating but it is throwing an error when doing so. It's probably a syntax error but I'm finding very little help online.

DynamicsWebApi.create({
        'ownerid_team@odata.bind': 'teams(A6DAE1B4-EDE0-EB11-BACB-000D3AE8540B)', 
        emailaddress1: 'something@anything.com',
        firstname: 'TEST',
        lastname: 'TEST',
        companyname: 'TEST',
        donotsendmm: true,
        subject: 'TEST',
        description: 'Dummy Lead to see how it creates them in CRM',
    }, 'leads')

Here's the error I receive: image

AleksandrRogov commented 3 years ago

@FlandersBurger can you please send me the request payload that is being sent by DynamicsWebApi?

AleksandrRogov commented 3 years ago

@FlandersBurger seems like you are specifying an incorrect navigation property. For Owning Team you need to use: owningteam.

<NavigationProperty Name="owningteam" Type="mscrm.team" Nullable="false" Partner="lead_owning_team">
    <ReferentialConstraint Property="_owningteam_value" ReferencedProperty="teamid"/>
</NavigationProperty>
<NavigationProperty Name="ownerid" Type="mscrm.principal" Nullable="false" Partner="owner_leads">
    <ReferentialConstraint Property="_ownerid_value" ReferencedProperty="ownerid"/>
</NavigationProperty>
<NavigationProperty Name="owningbusinessunit" Type="mscrm.businessunit" Nullable="false" Partner="business_unit_leads">
    <ReferentialConstraint Property="_owningbusinessunit_value" ReferencedProperty="businessunitid"/>
</NavigationProperty>
AleksandrRogov commented 3 years ago

I am pretty sure you could set ownerid without "team" suffix.