question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting value of Two Options type field

See original GitHub issue

Is there a method which allows for the setting of the value of an entity of type ‘Two Options’?

This seems like it should be the right method to call: xrmBrowser.Entity.SetValue(new OptionSet { Name = "bsp_highrisk", Value = "No" }); but in fact all it does is toggle the existing value.

Here’s a form with four such fields, two have a default Yes, two have a default No: defaults

If we try and set them all to No like this: xrmBrowser.Entity.SetValue(new OptionSet { Name = "bsp_highrisk", Value = "No" }); xrmBrowser.Entity.SetValue(new OptionSet { Name = "bsp_tradesanctionsapply", Value = "No" }); xrmBrowser.Entity.SetValue(new OptionSet { Name = "bsp_iscountry", Value = "No" }); xrmBrowser.Entity.SetValue(new OptionSet { Name = "bsp_isdemonym", Value = "No" }); we end up with values like this: allno and we end up with the same results if we try and set them to Yes. So I think all that is happening is that the ‘SetValue’ command is selecting the field and thereby toggling the value.

I also tried this: xrmBrowser.Entity.SetValue("bsp_highrisk", true); but this does nothing, which is to be expected as this is the method for checkboxes.

I could deal with this by checking the value of the field before changing it, but wondered if there is a better way to do this, or anything coming in a future release to address this.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bwmodularcommented, Oct 26, 2018

Thanks @SantoshDutt - That will work perfectly until the team add a more permanent fix to ‘SetValue’. Maybe I’ll even post a PR if I have time…

1reaction
SantoshDuttcommented, Oct 26, 2018

Hi @bwmodular,

I have also faced this issue and I am using this below scenario to overcome such risk. You can try this.

string IsCountryOptionPrior = xrmBrowser.Entity.GetValue(new OptionSet { Name = “bsp_iscountry” }); if (IsCountryOptionPrior == “Yes”) { xrmBrowser.Entity.SetValue(new OptionSet { Name = “bsp_iscountry”, Value = “No” }); } Or vice versa if you want any field to set it as Yes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java crm set values for field type Two Option
I want to set a field in mscrm whose data type is Two Option, for pick list data type i used OrganizationServiceStub.OptionSetValue but...
Read more >
How do I write back to the "two option" field of an entity
Value in the update property of the datacard. It wants an OptionSetValue. I set the values in the structure editor as "Ja" and...
Read more >
D365 – Implement Option Sets and Two Option Fields
Global Option Set: Can be used for multiple fields on multiple entities; Local Option ... Two Options is used when there are only...
Read more >
Get & Set value in fields using JavaScript
In this course, we will learn how to get and set value in various types of fields using JavaScript in Dynamics 365 CRM....
Read more >
No Default Value on Two Options Field Dynamics CRM 2011
Using a bit of JScript we can change the default value on a Two Options field from being “Yes” or “No” to being...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found