Undeclared property when creating a record via Web API In Dynamics CRM Online - dynamics-crm

I am trying to create an entity in Dynamics CRM online with a custom lookup field. Even after providing the SchemaName(sg_DepartmentalProjectId) as mentioned here 'An undeclared property' when trying to create record via Web API I am still getting the same error.
An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'sg_DepartmentalProjectId' 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.
Below is my JSON Post
{
"sg_invoicenumber": "SIAIR402742-416805",
"sg_accountnumber": "5400",
"sg_description": "xxxx",
"sg_fy": "20",
"sg_name": "Operational Journal: yyy - 09/20/2019",
"sg_departmentid": "CC10530",
"sg_postingdate": "2019-09-20",
"sg_invoicedate": "2019-09-20",
"sg_checkdate": "2019-09-20",
"sg_paidfulldate": "2019-09-24",
"sg_amount": 5597.4,
"sg_effectivedate": "2019-09-20",
"sg_DepartmentalProjectId#odata.bind":"/sg_departmentalmatters(e9c31cec-deff-e411-80c5-0050569732ae)"
}

Please Download Odata Metadata from the Developer resources & verify the exact casing. Jason Lattimer also confirmed that the bug while investigating the CRM REST builder issue:
I've come to figure out the metadata is in fact not the source of truth - it's the CSDL
I know it's super annoying when this is working different & getting solved by different solutions. Make sure you verify in all these places for the custom lookup attribute.
Microsoft reference: CSDL $metadata document

I had the same problem, but in my case using the schema name didn’t work. I believe it’s because my field is setup as a navigation property to either of two different entities. I found the correct name by pulling the metadata for the entity from the API and looking at the navigation properties. There were two navigation properties defined for this field, one for each target entity, so I had to use the name of the correct one in my payload.
<NavigationProperty
Name="parentcustomerid_account"
Type="mscrm.account"
Nullable="false"
Partner="contact_customer_accounts">
<ReferentialConstraint
Property="_parentcustomerid_value"
ReferencedProperty="accountid" />
</NavigationProperty>
The correct value was parentcustomerid_account above.

I had same issue
JSON:
{
"activityid": "cbf73794-9e42-ec11-8c62-00224815945f",
"subject": "Test 22",
"new_AppointmentTypeId#odata.bind": "new_tasktypes(a97ec3cf-3e1a-ea11-a811-000d3a799417)"
}
Error I was getting:
An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'new_AppointmentTypeId' 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.
Resolution:
Use Metadata Browser https://learn.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/browse-your-metadata?view=op-9-1
Find ReferencingEntityNavigationProperty from Metadata Browser for fields you need it.
Working JSON:
{
"activityid": "cbf73794-9e42-ec11-8c62-00224815945f",
"subject": "Test 22",
"new_AppointmentTypeId_Appointment#odata.bind": "new_tasktypes(a97ec3cf-3e1a-ea11-a811-000d3a799417)"
}

Related

Hyperledger Fabic 2.2.0 Error handling success response. Value did not match schema

I am using Hyperledger Fabric 2.2.0 and fabric-network 2.1 (not that important).
My chaincode is written in Go. So I have some structs which have ,omitempty in JSON tag. Here is my struct:
type LeaseDetails struct {
EndOfTerm string `json:"endOfTerm"`
Info string `json:"info,omitempty"`
Option string `json:"option,omitempty"`
}
But I am getting the following error as a return value from my chaincode:
peer=peer0.org1.example.com:7051, status=500, message=Error handling success response. Value did not match schema:
1. return.0.leaseDetails: info,omitempty is required
2. return.0.leaseDetails: option,omitempty is required
If I remove ,omitempty from my struct, and provide default value everything works fine.
In the docs for fabric-contract-api-go it is mentioned that there is some kind of serializer built upon json marshal/unmarshal, but to me it doesn't seem to detect the ,omitempty keyword.
Was this intentional? Or am I missing something here?
Thanks in advance
I got the answer on Hyperledger Chat from user #awjh.
This is as intended, the json is compared against the metadata schema.
By default all fields are required, using omitempty will mean that the
JSON process will remove that field when it has no value. This means a
required field will be missing. To fix this add a metadata tag to mark
the field as optional metadata:",optional"
So in my case, the solution is:
type LeaseDetails struct {
EndOfTerm string `json:"endOfTerm"`
Info string `json:"info,omitempty" metadata:",optional"`
Option string `json:"option,omitempty" metadata:",optional"`
}

What is global error (in spring validation)?

I'm checking spring-validation Errors(BindingResult) interface. It mentions global errors in contrast with field erros. What are global errors?
FieldError (javadoc)
registered via rejectValue (javadoc)
attached to a field
Example:
errors.rejectValue("name", "name.empty", "cannot be empty")`
ObjectError (global error) (javadoc)
registered via reject (javadoc)
not attached to a specific field (either multifield or not field related)
Examples:
errors.reject("password.mismatch", "Password doesn't match confirm password")
errors.reject("optimistic.out-out-date", "This page has been saved in the meantime. Reload it and start editing it again")

Trying to migrate Rally Defect Requirement to JIRA

Using the Rally/JIRA connection I am trying to synchronise them.
https://help.rallydev.com/jira-5-installation-user-guide
I am trying to map the Requirement (UserStory) field for Defects to a custom field in JIRA.
Here are my field mappings
<FieldMapping>
<Field><Rally>Name</Rally> <Other>Summary</Other></Field>
<Field><Rally>Description</Rally> <Other>Description</Other></Field>
<Field><Rally>FormattedID</Rally> <Other>RallyKey</Other></Field>
<Field><Rally>Status</Rally> <Other>Status</Other></Field>
<Field><Rally>Priority</Rally> <Other>Priority</Other></Field>
<Field><Rally>Requirement</Rally> <Other>RallyUserStory</Other></Field>
</FieldMapping>
I am using the RallyReferenceFieldHandler to map this to a custom field
<RallyReferenceFieldHandler>
<FieldName>Requirement</FieldName>
<ReferencedFieldLookupID>FormattedID</ReferencedFieldLookupID>
</RallyReferenceFieldHandler>
I am getting this error message:
RallyEIF::WRK::JiraRestConnection.block in validate - Field Handler field_name Requirement not found
would you mind posting more of your config with all of your field mappings and field handlers?
My only guess at the moment is that your is inside your block. If it were in the wrong place, you might get an error like you are seeing. It should be inside a block - for example:
<Connector>
<FieldMapping>
<Field><Rally>FormattedID</Rally><Other>OtherFormattedID</Other></Field>
<Field><Rally>Requirement</Rally><Other>RallyUserStory</Other></Field>
</FieldMapping>
<RallyFieldHandlers>
<RallyReferenceFieldHandler>
<FieldName>Requirement</FieldName>
<ReferencedFieldLookupID>FormattedID</ReferencedFieldLookupID>
</RallyReferenceFieldHandler>
<RallyFieldHandlers>
<OtherFieldHandlers>
<!-- Other Field Handlers here -->
</OtherFieldHandlers>
</Connector>

How to sync Tags to Labels with the RallyAPI and JIRA connector

I am using the RallyConnector to sync user stories and defects with JIRA.
https://help.rallydev.com/jira-5-installation-user-guide
here is my field mapping
<FieldMapping>
<Field><Rally>Name</Rally> <Other>Summary</Other></Field>
<Field><Rally>Description</Rally> <Other>Description</Other></Field>
<Field><Rally>FormattedID</Rally> <Other>RallyKey</Other></Field>
<Field><Rally>Tags</Rally> <Other>Labels</Other></Field>
</FieldMapping>
When I added the Tags field and map it to the Labels (JIRA's version of Tags) to the connector, I get the following error:
ERROR : RallyEIF::WRK::JiraRestConnection.rescue in attempt_update - Attempt to update issue JM-25 failed, undefined method `split' for # < RallyAPI::RallyCollection:0x007fd1950b2890 #results=[]>
I suppose this has something to do with the fact that it is a list of values, and just not a single value.
Only Bugzilla and CQ connectors support tags, but not the Jira connector. It's mentioned here, in the Best Practices. You are correct that in WS API Tags is a collection.

Microsoft AJAX: Unable to get property 'x' of undefined or null reference

How do I troubleshoot the following error being thrown by a Microsoft AJAX JavaScript framework method? It is an automatically generated line of JavaScript from a custom User Control in a Web Forms App (Sitefinity 5 CMS)
Error Message:
Unable to get property 'FancyBlockDesigner' of undefined or null reference
Here is the JavaScript that is throwing the error:
Sys.Application.add_init(function() {
$create(SitefinityWebApp.Esd.TheLab.SampleHtmlEditor.FancyBlockDesigner, null, null, {"Editor":"propertyEditor_ctl00_ctl00_ctl00_ctl00_ctl00_Editor","propertyEditor":"propertyEditor"}, $get("propertyEditor_ctl00_ctl00_ctl00"));
});
Rather than discuss the ascx and cs files that try to abstract this detail away from me, I want to know what this error means. If I understand the detail, the abstraction might make more sense.
"$create" function in ASP.NET Ajax creates an instance of JavaScript class. Microsoft had their own opinion on how to make JavaScript object orientated and as time had shown, their approach wasn't exactly perfect.
Anyhow, to try to explain what is happening, let me give a bit of an overview oh how it works. We start by a server side control which implements IScriptControl interface which mandates two members: GetScriptDescriptors and GetScriptReferences. The second one is pretty straightforward - it lets you register references to all JavaScript files that you control will require. The GetScriptDescriptors, on the other hand, let's you define all the instances of JavaScript classes you want to use as well as it lets you set their properties - initialize them, if you will.
What the autogenerated JavaScript code you've pasted says is basically that you have defined in GetScriptDescriptors that you will need an instance of type "SitefinityWebApp.Esd.TheLab.SampleHtmlEditor.FancyBlockDesigner" where you want Editor property to be initialized. This code will go and look for a JavaScript constructor that looks like this:
function SitefinityWebApp.Esd.TheLab.SampleHtmlEditor.FancyBlockDesigner(element) {
}
that most probably also has a prototype defined, something like:
SitefinityWebApp.Esd.TheLab.SampleHtmlEditor.FancyBlockDesigner.prototype = {
}
Now, since the error you have posted states: "Unable to get property 'FancyBlockDesigner' of undefined or null reference", most probably one of the following is the problem:
You have not included the JavaScript file which contains the class (constructor + prototype) that I've talked about above
You have forgot to add the "FancyBlockDesigner" to the constructor (it seems that you do have other object, perhaps through MS Ajax namespaces - "SitefinityWebApp.Esd.TheLab"
You have not registerd the "SampleHtmlEditor" namespace. Make sure at the top of your JS file you have this: Type.registerNamespace("SitefinityWebApp.Esd.TheLab.SampleHtmlEditor");
So, short story long, the function with name "SitefinityWebApp.Esd.TheLab.SampleHtmlEditor.FancyBlockDesigner" cannot be found.
Hope this helps,
Ivan

Resources