Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option set value 0 doesn't save on CRM #85

Open
wendyrepez opened this issue May 17, 2019 · 10 comments
Open

option set value 0 doesn't save on CRM #85

wendyrepez opened this issue May 17, 2019 · 10 comments

Comments

@wendyrepez
Copy link

wendyrepez commented May 17, 2019

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 wendyrepez changed the title I can sen option set with value 0 option set value 0 doesn't save on CRM May 17, 2019
@georged
Copy link
Contributor

georged commented May 19, 2019

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.

@wendyrepez
Copy link
Author

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.

@georged
Copy link
Contributor

georged commented May 28, 2019

@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?

@wizardist
Copy link
Collaborator

@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?

@wendyrepez
Copy link
Author

@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.

@georged
Copy link
Contributor

georged commented May 29, 2019

@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

@wendyrepez
Copy link
Author

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

@georged
Copy link
Contributor

georged commented May 30, 2019

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

@wendyrepez
Copy link
Author

wendyrepez commented May 31, 2019

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.

@georged
Copy link
Contributor

georged commented Jun 3, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants