AlexaCRM / dynamics-webapi-toolkit

Dynamics 365 Web API Toolkit for PHP
MIT License
75 stars 58 forks source link

Absent from inbound and outbound attribute maps #100

Closed Coysh closed 9 months ago

Coysh commented 9 months ago

Describe the bug Created new field in Dynamics. Ensured API user has the correct user security roles. The role appears in the GET but does not get returned via toolkit.

Log below

[2023-12-06T17:32:06.766354+00:00] my_logger.DEBUG: Completed GET https://redacted.crm9.dynamics.com/api/data/v9.0/py3_bankdetailses(63ceb234-5394-ee11-be36-002248004719) {"payload":null,"responseHeaders":{"Cache-Control":["no-cache"],"Allow":["OPTIONS,GET,HEAD,POST"],"Content-Type":["application/json; odata.metadata=minimal"],"Expires":["-1"],"ETag":["W/\"180315841\""],"x-ms-service-request-id":["128ba505-58a2-47d0-aca7-49345ceff624","7b6a27b1-5bbd-468d-ad2f-ab784d05138a"],"Set-Cookie":["ARRAffinity=8b0daae5dc4370447498a1b3b24bf7496ee476b366adf5ef8f88b50c68f46312dc748ed02332839cb0efbb9e2898da096c2226348c1e154ec1706e5f470d25ad08DBF685759C903A985743832; path=/; secure; HttpOnly"],"Strict-Transport-Security":["max-age=31536000; includeSubDomains"],"REQ_ID":["7b6a27b1-5bbd-468d-ad2f-ab784d05138a"],"CRM.ServiceId":["framework"],"AuthActivityId":["53551fd0-0efe-44fe-a89a-4592da9afec7"],"x-ms-dop-hint":["64"],"x-ms-ratelimit-time-remaining-xrm-requests":["1,199.97"],"x-ms-ratelimit-burst-remaining-xrm-requests":["7998"],"OData-Version":["4.0"],"Preference-Applied":["odata.include-annotations=\"*\""],"X-Source":["82267536232555620511492751812410322410337230331216849282151481121912024956137138","7725116194217311002341521910385127716423921214155157103152207235215860204111130139154"],"Public":["OPTIONS,GET,HEAD,POST"],"Date":["Wed, 06 Dec 2023 17:32:06 GMT"],"Content-Length":["4530"]},"responseBody":"{\"@odata.context\":\"https://redacted.crm9.dynamics.com/api/data/v9.0/$metadata#py3_bankdetailses/$entity\",\"@odata.etag\":\"W/\\\"180315841\\\"\",\"statecode@OData.Community.Display.V1.FormattedValue\":\"Active\",\"statecode\":0,\"statuscode@OData.Community.Display.V1.FormattedValue\":\"Awaiting Lodgement\",\"statuscode\":100000000,\"_py3_contactorganisation_value@OData.Community.Display.V1.FormattedValue\":\"TEST\",\"_py3_contactorganisation_value@Microsoft.Dynamics.CRM.associatednavigationproperty\":\"py3_ContactOrganisation_contact\",\"_py3_contactorganisation_value@Microsoft.Dynamics.CRM.lookuplogicalname\":\"contact\",\"_py3_contactorganisation_value\":\"fee0b84f-d55d-ee11-8def-002248c651e3\",\"createdon@OData.Community.Display.V1.FormattedValue\":\"06/12/2023 16:19\",\"createdon\":\"2023-12-06T16:19:27Z\",\"py3_icanconfirmiamtheaccountholder@OData.Community.Display.V1.FormattedValue\":\"No\",\"py3_icanconfirmiamtheaccountholder\":false,\"py3_bankaccountexpired@OData.Community.Display.V1.FormattedValue\":\"No\",\"py3_bankaccountexpired\":false,\"_ownerid_value@OData.Community.Display.V1.FormattedValue\":\"XXX\",\"_ownerid_value@Microsoft.Dynamics.CRM.associatednavigationproperty\":\"ownerid\",\"_ownerid_value@Microsoft.Dynamics.CRM.lookuplogicalname\":\"systemuser\",\"_ownerid_value\":\"8739848c-de40-ed11-bba2-0022481b5bd0\",\"modifiedon@OData.Community.Display.V1.FormattedValue\":\"06/12/2023 16:59\",\"modifiedon\":\"2023-12-06T16:59:34Z\",\"py3_collectionamount@OData.Community.Display.V1.FormattedValue\":\"\\u00a30.00\",\"py3_collectionamount\":0.0000000000,\"py3_collectionamount_base@OData.Community.Display.V1.FormattedValue\":\"\\u00a30.00\",\"py3_collectionamount_base\":0.0000000000,\"versionnumber@OData.Community.Display.V1.FormattedValue\":\"180,315,841\",\"versionnumber\":180315841,\"py3_bacscode@OData.Community.Display.V1.FormattedValue\":\"0N\",\"py3_bacscode\":100000000,\"py3_name\":\"TEST\",\"_transactioncurrencyid_value@OData.Community.Display.V1.FormattedValue\":\"British Pound\",\"_transactioncurrencyid_value@Microsoft.Dynamics.CRM.associatednavigationproperty\":\"transactioncurrencyid\",\"_transactioncurrencyid_value@Microsoft.Dynamics.CRM.lookuplogicalname\":\"transactioncurrency\",\"_transactioncurrencyid_value\":\"e616787f-0d3e-ed11-bba2-0022481b5cd7\",\"exchangerate@OData.Community.Display.V1.FormattedValue\":\"1.0000000000\",\"exchangerate\":1.000000000000,\"py3_recordnumber\":\"817504\",\"py3_banksortcode\":\"555555\",\"py3_detailslastchecked@OData.Community.Display.V1.FormattedValue\":\"06/12/2023\",\"py3_detailslastchecked\":\"2023-12-06\",\"py3_bankaccountnumber\":\"XXXXXXX\",\"_modifiedby_value@OData.Community.Display.V1.FormattedValue\":\"# App Dev\",\"_modifiedby_value@Microsoft.Dynamics.CRM.lookuplogicalname\":\"systemuser\",\"_modifiedby_value\":\"22958986-de40-ed11-bba2-0022481b5bd0\",\"_modifiedonbehalfby_value@OData.Community.Display.V1.FormattedValue\":\"XXX\",\"_modifiedonbehalfby_value@Microsoft.Dynamics.CRM.lookuplogicalname\":\"systemuser\",\"_modifiedonbehalfby_value\":\"1adb9ecf-db40-ed11-bba2-0022481b5f9a\",\"py3_bankreference\":\"817504\",\"ea_paperlessdirectdebit@OData.Community.Display.V1.FormattedValue\":\"No\",\"ea_paperlessdirectdebit\":false,\"timezoneruleversionnumber@OData.Community.Display.V1.FormattedValue\":\"0\",\"timezoneruleversionnumber\":0,\"_createdby_value@OData.Community.Display.V1.FormattedValue\":\"XXX\",\"_createdby_value@Microsoft.Dynamics.CRM.lookuplogicalname\":\"systemuser\",\"_createdby_value\":\"8739848c-de40-ed11-bba2-0022481b5bd0\",\"_owningbusinessunit_value@OData.Community.Display.V1.FormattedValue\":\"General\",\"_owningbusinessunit_value@Microsoft.Dynamics.CRM.associatednavigationproperty\":\"owningbusinessunit\",\"_owningbusinessunit_value@Microsoft.Dynamics.CRM.lookuplogicalname\":\"businessunit\",\"_owningbusinessunit_value\":\"a05d8390-ebfc-eb11-94ef-0022481b40bd\",\"py3_bankdetailsid\":\"63ceb234-5394-ee11-be36-002248004719\",\"_owninguser_value@Microsoft.Dynamics.CRM.lookuplogicalname\":\"systemuser\",\"_owninguser_value\":\"8739848c-de40-ed11-bba2-0022481b5bd0\",\"py3_membernumber\":\"817504\",\"py3_firstdd@OData.Community.Display.V1.FormattedValue\":\"Yes\",\"py3_firstdd\":true,\"importsequencenumber\":null,\"py3_progressstatus\":null,\"py3_ddcancelleddate\":null,\"py3_startdate\":null,\"py3_sortcode\":null,\"ea_verificationresults\":null,\"utcconversiontimezonecode\":null,\"py3_activationdate\":null,\"ea_validationresults\":null,\"overriddencreatedon\":null,\"py3_bankname\":null,\"py3_enddate\":null,\"py3_dmid\":null,\"py3_accountholdersname\":null,\"py3_datelodged\":null,\"py3_lodgementdate\":null,\"py3_accountnumber\":null,\"_owningteam_value\":null,\"_createdonbehalfby_value\":null}"} []
[2023-12-06T17:32:06.766692+00:00] my_logger.DEBUG: Received py3_bankdetails[ea_paperlessdirectdebit] from Web API which is absent in the inbound attribute map {"field":"ea_paperlessdirectdebit","inboundMap":{"py3_detailslastchecked":"py3_detailslastchecked","importsequencenumber":"importsequencenumber","timezoneruleversionnumber":"timezoneruleversionnumber","py3_progressstatus":"py3_progressstatus","_modifiedby_value":"modifiedby","py3_ddcancelleddate":"py3_ddcancelleddate","py3_collectionamount":"py3_collectionamount","py3_bankaccountexpired":"py3_bankaccountexpired","py3_recordnumber":"py3_recordnumber","versionnumber":"versionnumber","py3_startdate":"py3_startdate","py3_sortcode":"py3_sortcode","_py3_contactorganisation_value":"py3_contactorganisation","_modifiedonbehalfby_value":"modifiedonbehalfby","py3_name":"py3_name","_createdby_value":"createdby","py3_collectionamount_base":"py3_collectionamount_base","utcconversiontimezonecode":"utcconversiontimezonecode","py3_activationdate":"py3_activationdate","py3_bankreference":"py3_bankreference","py3_bacscode":"py3_bacscode","py3_membernumber":"py3_membernumber","overriddencreatedon":"overriddencreatedon","_owningbusinessunit_value":"owningbusinessunit","_transactioncurrencyid_value":"transactioncurrencyid","_ownerid_value":"ownerid","py3_enddate":"py3_enddate","statecode":"statecode","py3_icanconfirmiamtheaccountholder":"py3_icanconfirmiamtheaccountholder","py3_banksortcode":"py3_banksortcode","py3_bankname":"py3_bankname","modifiedon":"modifiedon","py3_firstdd":"py3_firstdd","py3_dmid":"py3_dmid","_owninguser_value":"owninguser","py3_accountholdersname":"py3_accountholdersname","_createdonbehalfby_value":"createdonbehalfby","statuscode":"statuscode","py3_datelodged":"py3_datelodged","exchangerate":"exchangerate","py3_lodgementdate":"py3_lodgementdate","py3_accountnumber":"py3_accountnumber","_owningteam_value":"owningteam","py3_bankdetailsid":"py3_bankdetailsid","py3_bankaccountnumber":"py3_bankaccountnumber","createdon":"createdon"}} []
georged commented 9 months ago

After you add a column to the table you need to:

  1. Publish the table. Strictly speaking is not required but wouldn't hurt.
  2. Refresh the metadata cache. Simply reestablishing the connection is one way to flush the metadata.

Have you done the above?

Coysh commented 9 months ago

Hi @georged - thanks. A server restart worked in this case. For the future, how would you go about refreshing the meradata cache? Creating new API credentials?

georged commented 9 months ago

@Coysh you shouldn't need server restart or creating new creds or even reconnecting. Toolkit uses whatever cache implementation was provided when instantiating the connection. So, it's up to you to handle the cache refresh.

Metadata is cached here: https://github.com/AlexaCRM/dynamics-webapi-toolkit/blob/e15a16d96ec643abbf5b3df69de42a1acd4b7be2/src/WebAPI/OData/Client.php#L140.

Coysh commented 9 months ago

@georged - Interesting, I haven't specified a custom cache pool. I've got OPCache enabled, but that was reset multiple times and as far as I know it doesn't cache on that sort of level.

This can be marked as closed. Hopefully will be helpful for someone in the future.