Microsoft Dynamics 365 CRM - populate a lookup field

Using Microsoft Dynamics 365 CRM and having a problem trying to populate a field in one of our entities that is a lookup field (requires a GUID to be saved).

I think when doing this through the RESTAPI directly you have to use something more like

“new_field@odata.bind” : “/lookupentity(GUID HERE)”

Any idea how to do this in the UPDATE activity

Here is what the error is

ResponseStatus
{
AdditionalDetails=null,
ErrorCode=“0x0”,
Message=@“An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property ‘new_fieldname’ which only has property annotations in the payload but no property value was found in the payload. In OData,
only declared navigation properties and declared named streams can be represented as properties without values.
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadUndeclaredProperty(IODataJsonLightReaderResourceState resourceState,
String propertyName,
Boolean propertyWithValue)
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithoutValue(IODataJsonLightReaderResourceState resourceState,
String propertyName)
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass9_0.b__0(PropertyParsingResult propertyParsingResult,
String propertyName)
at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector,
Func2 readPropertyAnnotationValue, Action2 handleProperty)
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState)
at Microsoft.OData.JsonLight.ODataJsonLightReader.StartReadingResource()
at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceSetItemStart(PropertyAndAnnotationCollector propertyAndAnnotationCollector,
SelectedPropertiesNode selectedProperties)
at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyAndAnnotationCollector propertyAndAnnotationCollector)
at Microsoft.OData.ODataReaderCore.ReadImplementation()
at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action)
at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)
at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader,
Type type,
ODataDeserializerContext readContext)
at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type,
Stream readStream,
HttpContent content,
IFormatterLogger formatterLogger)”,
Success=false
}

1 Like

Hey @FMCgclifford

Sorry, actually I can’t correlate the issue you are facing.

Please check below docs - https://docs.uipath.com/activities/docs/microsoft-dynamics-365-update-record

If the above doesn’t help, Kindly let us know for more help with screenshots please.

Thanks
#nK

Hello,

I reviewed the docs before posting - there is nothing relevant to my problem.

Fields in Dynamics CRM can be three types

static fields (string, int, etc)
choice fields (an integer that represents a choice with a text label)
lookup field (a field that contains a GUID that references a record in another entity)

In this example the field I am trying to populate is called new_field and it expects a GUID (which is a reference number) for an entry in another entity. A good example would be a contact and account scenario.

Every contact in the system has a unique GUID that identifies them in the system. When you create an account you set the account_owner field to be the GUID for the contact.

Now - to my problem. When I try to put the GUID in the field I get the error that I provided above. UiPath is likely translating its update into this REST call

PATCH https://url/api/data/v9.2/account and then the body will contain

“new_fieldname” : “/entityname(record GUID)”

But for lookup fields you would need to do this

PATCH https://url/api/data/v9.2/account and then the body will contain

“new_fieldname@odata.bind”: “/entityname(record GUID)”

how do I accomplish this?

1 Like

Hey @FMCgclifford

Could you please show the activity screenshot once like what & how you are exactly doing there?

Also please share the Dynamics CRM API docs link from where you found those PATCH type request details.

Hope this helps.

Thanks
#nK

Hello,

I’m not sure that a screenshot will help anyone here - it is just an Update activity with a simple text string.

Here is the data about odata.bind

here is a user explaining the same

Are you able to add the lookup value to CRM? Any solution

Actually, I a facing a problem while inserting the record (Lookup Filed value) into the appointment entity.
Till now I am successfully able to enter the string, Int, and Boolean Data types of data but I am not getting the fields in the list to add the lookup type of data,
For example, the ‘RequiredAttendees’ field in the appointment entity or ‘ToEmail ID’ or ‘CC_Email’ id in the Email entity.

Can anyone please help me with this?

UiPath would need to fix this.

Basically you need to build your own interface using the REST call to Dynamics which makes the activities useless.

Thank you for your response, it is very helpful for me.

Hi,

I’ve got the same issue when I try to use the activity “Insert Record”. My table has a lookup column and it seems that I can’t insert any data in this column. I’ve got the following error message:

Error: System.Exception: The value ‘“XXXX”’ for field ‘XXXX’ does not reference a valid entityset.

When I try a POST request with Postman, no issue. I use the ““XXXX@odata.bind”:”/XXXX(value)"

I wanted to know if there is any update on this bug or do I need to use the REST activity?

If no update, I agree with @FMCgclifford, Microsoft Dynamics activities are becoming useless if we can’t add data to a lookup column.