How to create a contact record with customer field set as contact or account - dynamics-crm

I am trying to create a contact record with its customer set to Account/Contact where customer records are pre-existing.
Here is the request that I am trying.
POST <service>/api/data/v8.0/contacts
{
'lastname':’contact1’,
'parentcustomerid_contact': '/contacts(f797401d-64c9-e711-8125-000d3a22f66f)'
}
I also tried providing full url of the contact record, but that is also not working. Appreciate any help with correct query or any document that I shall go through to get this scenario working.

You have to use like this parentcustomerid_contact#odata.bind to bind single valued navigation properties.
you must use the #odata.bind annotation to set the value of a single-valued navigation property.
Read more

Related

Microsoft Dynamics API - Getting Fields from Entity with Navigation

I am trying to get the field list from an entity, in example contact, I have successfully done it doing a Request to:
EntityDefinitions(LogicalName='contact')/Attributes/Microsoft.Dynamics.CRM.AttributeMetadata
But now I need to get the Navigation Properties defined on this entity, I have found information on how to get Navigation Properties when querying a specific record by id, but in this case I need it when getting the field list.
Thanks in advance for your help
Referring the docs: https://learn.microsoft.com/en-us/powerapps/developer/data-platform/webapi/query-metadata-web-api
You already have the Lookup attributes, AttributeMetadata has everything.
If you want to only read the metadata of lookups, change the type to LookupAttributeMetadata.
EntityDefinitions(LogicalName='contact')/Attributes/Microsoft.Dynamics.CRM.LookupAttributeMetadata
To obtain relationships info alongside the columns list then an additional query is required, RelationshipDefinitions:
/RelationshipDefinitions/Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata
/RelationshipDefinitions/Microsoft.Dynamics.CRM.ManyToManyRelationshipMetadata
filter on ReferencedEntity / ReferencingEntity to limit the results
/RelationshipDefinitions/Microsoft.Dynamics.CRM.ManyToManyRelationshipMetadata
filter on Entity1LogicalName / Entity2LogicalName / IntersectEntityName

How to use Get Record to lookup a related record on another object when I don't have the schema Entity Name - Just the LogicalName

All,
I am building a Power Flow. I am returning an object that has a relationship to another entity.
I want to get some values from the related entity.
I am attemping to use the "Get Record" connector. The returning object returns just the logicalEntityName (in this case "opportunities") but Get Record wants an Entity Name that is the Schema Name ("Working Opportunities").
Big Question: What's the secret to use CDS to get information from a related record in another object?
Little Question: How do I do get the Schema Name?
The logical name will be the same as schema name except some casing difference, ie schema name will have camel casing (first letter of first/second word with capitals, you can notice it clearly in custom entity which will have publisher prefix like new_entityname) and logical name will have pascal casing (all lower case).
You can find the details in XrmToolBox metadata browser or in Solution.
In the below snip, (Logical) Name = Opportunity and Schema Name = Opportunity, also Display Name can be anything and can be changed anytime.
Regarding the related entities, you should use List Records: GetItems_V2 and you can use filter by passing parent record to get related child records. Read more
Could you please share flow screenshot and response to help you with your requirement?
As suggested by Arun you could use List Record and filter query to pass parent record id which will be available from dynamic content.
see below link.
https://crmkeeper.com/2019/08/31/cds-list-records-filter-query-using-flow/
Please mark my answer verified if i were helpful

How do I select Dynamics CRM reference attributes?

Please read the follows and tell me what I did wrong.
The request I sent:
https://gravityrush.crm5.dynamics.com/api/data/v9.1/accounts?$expand=ownerid/$ref
The response I expected:
"ownerid":{
"#odata.type":"#Microsoft.Dynamics.CRM.systemuser",
"#odata.id":"https://gravityrush.crm5.dynamics.com/api/data/v9.0/systemusers(41041b99-e1ae-46c6-a10c-95ce77fc0b18)"
}
The response I received:
"ownerid":{
"#odata.type":"#Microsoft.Dynamics.CRM.systemuser",
"#odata.id":"https://gravityrush.crm5.dynamics.com/api/data/v9.1/owners()"
}
Thank you.
I think it's possibly a limitation/bug related to this field type.
As you know, the ownerid field can point to a systemuser or team record, and if you take a look at the field definition you'll see that the relationship is actually to an entity called Owner, and that's why you're getting the owners() url:
"#odata.id":"/api/data/v9.1/owners()"
I tried to workaround this using the owninguser and owningteam fields, but it looks like there's an issue there as well because when I added the $ref I started to get nulls values for that field:
GET /api/data/v9.1/accounts?$select=accountid&$expand=owninguser($select=systemuserid)
"owninguser":{
"systemuserid":"f30a6a42-3067-4c78-b348-9cbc56531f5e",
"ownerid":"f30a6a42-3067-4c78-b348-9cbc56531f5e"
}
GET /api/data/v9.1/accounts?$select=accountid&$expand=owninguser/$ref
"owninguser":null
Just to be sure, I tried to do the same for a Customer field (kind of same principle where this field can point to a contact or account record) but I din't found this issue, you can get the reference to the Account/Contact using the following query:
GET /api/data/v9.1/incidents?$select=incidentid&$expand=customerid_account/$ref, customerid_contact/$ref
Try to send API query as below and you shall have the OwnerId
https://orgurl/api/data/v8.2/accounts()?$select=_ownerid_value
You will get OwnerId of each account Record.

Joomla Component Dynamic Custom Field based on other Field Value

I am creating a new Joomla Component. I am able to create custom fields for the component backend forms - but I am not able to create Dynamic Custom Fields.
What I would like to do is have a field that is dynamical populated based on the value of a previous field. The easiest way to explain this is the simple country,state,city breakdown.
Field 1 = Country
Field 2 = State (Based on what the user selected as as Country in Field 1)
Field 3 = City (Based on what the user selected as State in Field 2)
The fields would of course need to be refreshed, reset as the user picks a different country etc.
The data to populate the fields would also all need to come from a database based on the previous fields value.
I am guessing this needs to be done via ajax or javascript or something? But wondering if there is an official way? Especially since there are database calls involved.
Please let me know if there is anything I can explain better..
David
I ended up just creating text fields but then validating the input to make sure the values added are correct.

how to create an ajax-driven auto-complete field in a sonata admin form in symfony?

I have a form generated with the sonata admin bundle. I want to enable a live search tip for my user on an input field. The proposition should come from a category table in the DB.
For example, if I have a field called company, when a user writes "a", I should suggest all companies whose name contains "a".
Use JQuery Autocomplete. On server side create controller action that will return suggestions through AJAX.
See example - http://jqueryui.com/autocomplete/#remote-jsonp

Resources