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 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
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,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156