Martin Felber
Martin Felber

Reputation: 121

Optional Input parameters in CRM action always NULL in Code Activity even if not passed?

If I ommit an optional input parameter in a CRM action call, will this parameter always be null in the Code Activity?

We have a customer which calls a particular CRM action, lets say an update action. The customer wants to be able to pass input parameters as null if the value in the corresponding field in dynamics must be deleted.

the problem i an facing now is that I cannot detect wether the input variable was effectively passed like "parameter_1 = null" or if the parameter itself was not even passed in the action call. the issue is that I cannot delete the value in crm if the input parameter was just not passed. only if the parameter was passed with the value null, I am allowed to delete the field value in crm.

Am I correct assuming that the value of a optional action input parameter is also null if the parameter is not passed at all?

Is there maybe a workaround which enables me to detect wether the value of the input parameter was passed as null instead of beeing ommitted?

something like "undefined" or similar?

Upvotes: 1

Views: 1272

Answers (1)

Henk van Boeijen
Henk van Boeijen

Reputation: 7918

You are correct. Input parameters are always present in the IPluginExecutionContext.InputParameters collection passed to the plugin handling your action.

You would need an extra "MyParameterNameSpecified" so to speak to signal if the parameter null value was actually passed.

Another option could be to use a string parameter holding the value passed in JSON-serialized form.

Upvotes: 1

Related Questions