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
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.
get the opportunity entity record store it in a variable (for ex. objOpp).
if(objOpp.GetAttributeValue<OptionSet>("statecode").Value == 1)
{
//opp is won
}
can you give me C# code to check weather oppurtunity is closed or open
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
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Andrés Arias as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Aric Levin - MVP 2 Moderator
HR-09070029-0 2
MA-04060624-0 1