CRMOpportunity.CalculateActualValue Method
The CalculateActualValue method calculates the actual value of the opportunity.
Note In Microsoft CRM Version 1.2, this method calculates only those opportunities with the state of 'Won'. Microsoft CRM Version 1.0 included all opportunities, regardless of their state.
Syntax
[Visual Basic .NET]
Public Function CalculateActualValue(
ByVal Caller As CUserAuth,
ByVal OpportunityId As String,
ByVal Object As ObjectType
) As String
[C#]
public string CalculateActualValue(
CUserAuth Caller,
string OpportunityId,
ObjectType Object
);
[C++]
public: String* CalculateActualValue(
CUserAuth* Caller,
String* OpportunityId,
ObjectType Object
);
Parameters
Caller
Specifies the identity of the caller. To perform this action, the caller must have the prvReadOpportunity privilege and access rights on the object. See CUserAuth.
OpportunityId
Specifies the ID of the opportunity.
ObjectType
Specifies the type of the object (quote). See ObjectType.
Return Value
Returns a String type that specifies the actual value of the opportunity.
Remarks
If there is an error, SOAP throws an exception and the error message is reported in System.Web.Services.Protocols.SoapException.Detail.OuterXml.
All IDs passed to the platform are GUIDs wrapped in braces. For example: {6522D89A-A752-4455-A2B0-51494C6957C3}
Example
[C#]
// strServer should be set with the name of the platform Web server
string strServer = "myservername";
// virtualDirectory should be set with the name of the Microsoft CRM
// virtual directory on the platform Web server
string virtualDirectory = "mscrmservices";
string strDir = "https://" + strServer + "/" + virtualDirectory + "/";
// BizUser proxy object
Microsoft.Crm.Platform.Proxy.BizUser bizUser = new Microsoft.Crm.Platform.Proxy.BizUser ();
bizUser.Credentials = System.Net.CredentialCache.DefaultCredentials;
bizUser.Url = strDir + "BizUser.srf";
// CRMOpportunity proxy object
Microsoft.Crm.Platform.Proxy.CRMOpportunity opportunity = new Microsoft.Crm.Platform.Proxy.CRMOpportunity();
opportunity.Credentials = System.Net.CredentialCache.DefaultCredentials;
opportunity.Url = strDir + "CRMOpportunity.srf";
string strErrorMsg;
try
{
Microsoft.Crm.Platform.Proxy.CUserAuth userAuth = bizUser.WhoAmI();
string strOpportunityId = "{C0389BC8-2715-49DD-A95C-58E5215CE5A7}";
// Now calculate the actual value for the opportunity
string strValue = opportunity.CalculateActualValue(userAuth, strOpportunityId, Microsoft.Crm.Platform.Proxy.ObjectType.otQuote);
}
catch (System.Web.Services.Protocols.SoapException err)
{
// Process the platform error here
strErrorMsg = ("ErrorMessage: " + err.Message + " " + err.Detail.OuterXml + " Source: " + err.Source );
}
catch (Exception err)
{
// Process other errors here
strErrorMsg = ("ErrorMessage: " + err.Message );
}
Requirements
Namespace: Microsoft.Crm.Platform.Proxy
Assembly: Microsoft.Crm.Platform.Proxy.dll
See Also