Couple of months ago, I have to face a strange error and its very strange solution. So I decide to share it and document so it helps others as well as I remember if I face it again.
Error occur when we try to create, edit or delete workflow. This error is certainly because of time zone. And As we are in Pakistan so certainly the Legal entity have to use local time zone.
But interestingly Workflow works fine in all other legal entity with same time zone. So what is problem with certain legal entity.
Short detail of error is as follow
‘Invalid enum value ‘GMTPLUS0500ISLAMABAD_KARACHI’ cannot be deserialized into type ‘Microsoft.Dynamics.AX.Framework.Workflow.Model.AxWorkflowServiceReference.Timezone
This error occurs when following statement execute.
workflowConfiguration = Microsoft.Dynamics.AX.Framework.Workflow.Model.WorkflowModel::
Create(templateName, curext(), curUserId(), domainUser);
As per my understanding we cannot debug framework classes. So We cannot get understand what cause problem.
After efforts, I found that this error is caused by time zone set in legal entity’s primary Address instead of legal entity’ own time zone. I changed it to Central time zone US and Canada, Everything starts to working fine. I am surprised, what logic required to create Workflow based on Primary Address time zone.
The detail error message is looked like
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ServiceModel.Dispatcher.NetDispatcherFaultException: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org:response. The InnerException message was ‘Invalid enum value ‘GMTPLUS0500ISLAMABAD_KARACHI’ cannot be deserialized into type ‘Microsoft.Dynamics.AX.Framework.Workflow.Model.AxWorkflowServiceReference.Timezone’. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.’. Please see InnerException for more details. —> System.Runtime.Serialization.SerializationException: Invalid enum value ‘GMTPLUS0500ISLAMABAD_KARACHI’ cannot be deserialized into type ‘Microsoft.Dynamics.AX.Framework.Workflow.Model.AxWorkflowServiceReference.Timezone’. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.
If we see description that problem is conversion between two time Zone. On comparison
I found time zone enum “Microsoft.Dynamics.AX.Framework.WorkFlow.Model.AXWorkflowServiceReference.TimeZone” did not have GMTPLUS0500ISLAMABAD_KARACHI.