I have an option set in avd_masteraction entity
schemaName of optionset --> avd_FollowUpRetainOwnerShip
name of option set-->avd_followupretainownership
It has the values
Retain Ownership -->label 100,000,000-->value
Send For Allocation -->label 100,000,001-->value
Depending on the option selected in the option set, i have to change the status field value.
For this i have written the below code.
avd_masteraction newPa = new avd_masteraction();
OptionSetValue subStage = (OptionSetValue)newPa.Attributes["avd_FollowUpRetainOwnerShip"];
int selectedSubStage = subStage.Value;
if (selectedSubStage == (int)avd_masteraction_followupretainownership.SendForAllocation) -->not working
{
newPa.statuscode = new OptionSetValue(avd_masteraction_statuscode.AwaitingAllocation.GetHashCode()); -->this line is working fine
}
if (selectedSubStage == (int)avd_masteraction_followupretainownership.Retain Ownership)
{
newPa.statuscode = new OptionSetValue(avd_masteraction_statuscode.Allocated.GetHashCode());
}
Please tell me where i am going wrong?
*This post is locked for comments
Hi,
Try the following code. Hope it works.
avd_masteraction newPa = new avd_masteraction();
int selectedSubStage = ((OptionSetValue) entity["avd_followupretainownership"]) .Value; if (selectedSubStage == 100000001) { newPa.statuscode = new OptionSetValue(avd_masteraction_statuscode.AwaitingAllocation.GetHashCode()); } if (selectedSubStage == 100000000) { newPa.statuscode = new OptionSetValue(avd_masteraction_statuscode.Allocated.GetHashCode()); }
Thanks
Hi,
Try this to retrieve optionset value...
String text = entity.FormattedValues["yourattributename"].ToString();
int value = ((OptionSetValue)entity["yourattributename"]).Value;
Thanks
Hi,
Try following code for retrieve optionset
int optValue=newPa.GetAttributeValue<OptionSetValue>("avd_FollowUpRetainOwnerShip").Value;
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156