02-17-2015 03:53 PM
I am doing my next round of code, with a set of checkbox (Yes/No)
I want to be able run through each checkbox and if its checked run a bit of code to set up a new opportunity, and some new activities
However i can not work out the checkbox, I have tried different variations but this is the only thing that does not come up with an error message, unfortunetly it does not work as the code runs regardless of it its checked or not
if (c.Fields["CUST_ContactTable1_090144.CUST_ProdLife_065924792", true] != null)
I have another peice of code that get the value and it appears to work fine so i have tried .ToString = "Yes" but that does not work
Any guidance would be great
02-17-2015 09:28 PM
if (c.Fields["CUST_ContactTable1_090144.CUST_ProdLife_065924792", true] != false)
02-18-2015 12:40 PM
02-18-2015 12:50 PM
I find it rather strange as i have this
string LifeProd = c.Fields["CUST_ContactTable1_090144.CUST_ProdLife_065924792", true].ToString();
Which works fine as it flows into another If statement creating a activity with the answer to this line as True or False in a string format
So i tried this
if (LifeProd = "True")
To me that should have worked.... nope
02-18-2015 01:51 PM
I suspect the reason is because it is a lower case "T" in "true".
02-18-2015 01:52 PM
I don't use "!=" having a mostly vb.net background but if that's the case then I would go with "<>" which does work in vb.net but might not work in cs.net.
02-18-2015 02:13 PM
02-18-2015 02:17 PM
02-18-2015 02:24 PM
It appears to me that you aren't comparing apples to apples. After a quick test (using Intellisense) with a company, the Fields property is a MutableEntity.FieldCollection. That means, or at least should mean, that the object returned by it will be a MutableEntityFieldDescriptor. So, in short, it looks like you are trying to compare a FieldDescriptor object with a boolean value (object type vs. value type). That's never going to work.
I think you need another step in there. Can you declare a FieldDescriptor object, and assign it the object of c.Fields by converting your c.Fields object into a FieldDescriptor? Then, does comparing FieldDescriptor.GetValue(c) with your boolean value work?
I apologize if the wording is a bit weird.
02-18-2015 02:35 PM