Announcements
No record found.
Hi Guys,
I m writing a plugin in which is need to check weather oppurtunity is open , close , won or lost .
pls help
Thsnks
*This post is locked for comments
Check Status(statecode) and Status Reason(statuscode) field values in your plugin.
Values can be found from this link
https://technet.microsoft.com/en-us/library/dn531157.aspx
can you give me C# code to check weather oppurtunity is closed or open
get the opportunity entity record store it in a variable (for ex. objOpp).
if(objOpp.GetAttributeValue<OptionSet>("statecode").Value == 1)
{
//opp is won
}
Hi,
Try the code below.
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { // Obtain the target entity from the input parameters. Entity entity = (Entity)context.InputParameters["Target"]; // Verify that the target entity represents an opportunity. // If not, this plug-in was not registered correctly. if (entity.LogicalName != "opportunity") return; try { int stateCode = GetAttributeValue<OptionSetValue>("statecode").Value; if(stateCode == 0) { //Open Opportunity } if(stateCode == 1) { //Won Opportunity } if(stateCode == 2) { //Lost Opportunity } } }
Hope this helps.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
JS-09031509-0 3
AS-17030037-0 2
Mark Eckert 2