I am working on mvc-5 with dynamic-crm. In crm i have a optionsetValue for state-code with the value (publish,deactivate,draft). Now my first question is how do i set these value in my C# code,by default it should be draft. The second is how do i change the state-code value on button click(say when i click on publish button the state should change to publish from draft). below is the code that i have in my model
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("statuscode")]
public Microsoft.Xrm.Sdk.OptionSetValue statuscode
{
get
{
return this.GetAttributeValue<Microsoft.Xrm.Sdk.OptionSetValue>("statuscode");
}
set
{
this.SetAttributeValue("statuscode", value);
}
}
[DisplayName("Status")]
[Display(Name = "Status")]
public string Status
{
get
{
if(statuscode == null)
{
OptionSetValue setValue = new OptionSetValue();
setValue.Value = 1;
return Status = "Draft";
}
return Status = statuscode.Value.ToString() == "1" ? "Publish" : "Draft";
}
set
{
}
}
Thanks in advance!!