php-crm-toolkit icon indicating copy to clipboard operation
php-crm-toolkit copied to clipboard

option set value 0 doesn't save on CRM

Open wendyrepez opened this issue 5 years ago • 10 comments

Hi,

I'm trying to send to CRM an option value of 0 without luck. If I send a value different than 0, I can see it correctly on CRM. But this doesn't happen when I send 0. Can you give an example or any other guidance of how should I do this? I'm using the optionValue method , but that does not work when I'm attempting to send 0

wendyrepez avatar May 17 '19 18:05 wendyrepez

Is 0 a valid value for your optionset? If not then what are you trying to do - set the value to null? Null and 0 are not the same.

georged avatar May 19 '19 08:05 georged

Hi georged, 0 is a valid value on my optionset, and that's what I'm being trying to send to CRM.

If I send any other number to those optionsets all of them work, the issue is with the 0.

Any clue about why this could happen will be appreciated.

wendyrepez avatar May 28 '19 15:05 wendyrepez

@wendyrepez that is strange, indeed. Do you get any error or operation just completes and does not save? Could it be that you have some plugins or workflows that prevent the value from saving?

georged avatar May 28 '19 23:05 georged

@wendyrepez make sure you are using the latest version of toolkit @ dev-master.

I tried both setting the integer value 0 and new OptionSetValue( 0, '' ), and it worked fine. Could you share with us the way you update values?

wizardist avatar May 29 '19 09:05 wizardist

@wendyrepez that is strange, indeed. Do you get any error or operation just completes and does not save? Could it be that you have some plugins or workflows that prevent the value from saving?

Yes, It is. I don't get any error and the operation completes successfully, but the option doesn't get save on CRM.

I could give it a check it out to plugins or workflows but this behaviour occurs with all the optionsets which have 0 as value.

wendyrepez avatar May 29 '19 17:05 wendyrepez

@wendyrepez as @wizardist mentioned, we did test it and found no issues. I assume your toolkit is up to date. Can you please:

  • Tell us the Dynamics 365/CRM version you're using
  • Show the fragment of code that is causing the drama

Thanks George

georged avatar May 29 '19 23:05 georged

Hi @georged,

We are using Dynamics 365/CRM on its 9.1 version

Here I left you the fragment of code, that seems to be causing no efect on CRM:

if($inputName=='new_sexo' || $inputName=='new_laborandoactualmente' || $inputName=='new_espep' || $inputName=='new_motivopepbenfinal' || $inputName=='new_porvinculacionfamiliar' || $inputName=='new_suma_toleranciadelclientealriesgo'|| $inputName=='new_tipodeorganizacionoempresa' || $inputName=='new_nivelacademico' || $inputName=="new_suma_plazoqueanticipadelosfondosinvertido"){ $value = ($data['value']=="0" ? 0 : $data['value']); $lead->$inputName = optionValue($value,''); }

The data always come to the function as string and those lines are wrap on a foreach . All of those fields receive all values except 0 .

Hope this can give you an idea. Let me know if you have any other doubt or need more information.

Thanks in advance, @georged and @wizardist

wendyrepez avatar May 30 '19 19:05 wendyrepez

@wendyrepez why are you casting "0" to 0 but not any other values?

georged avatar May 30 '19 23:05 georged

Hi @georged,

That was just a try, even if I don't cast the value, the method doesn't take effect for 0, the operation gets completed successfully but the value doesn't get save.

wendyrepez avatar May 31 '19 14:05 wendyrepez

Hi @wendyrepez

we are unable to reproduce the issue. All our tests involving optionsets with the value 0 pass.

What you can do is instantiate the client with the logger attached, i.e.

new Client( $settings, $cache, $logger )

where $logger is an instance of a PSR-3 compliant logger, e.g. Monolog.

Logger will "see" all details of the requests including SOAP that gets sent out and the responses. That should help you to identify the issue.

Thanks George

georged avatar Jun 03 '19 09:06 georged