P
Phil Adams
Hi Peeps,
I am trying to do some custom programming for CRM, but alas i am only a
classic asp programmer.
Can someone help me by translating this into asp.net in VB instead of C#, i
can then get on as i think i am okay with the rest only not too clever with
imports etc.
This is in the CRM SDK under CRMIncident.Open Method.
Thanks In Advance
[C#]
// server should be set with the name of the platform Web server
string server = "myservername";
// virtualDirectory should be set with the name of the Microsoft CRM
// Virtual Directory on the platform Web server
string virtualDirectory = "mscrmservices";
string strDir = "http://" + server + "/" + virtualDirectory + "/";
// BizUser proxy object
Microsoft.CRM.Proxy.BizUser bizUser = new Microsoft.CRM.Proxy.BizUser ();
bizUser.Credentials = System.Net.CredentialCache.DefaultCredentials;
bizUser.Url = strDir + "BizUser.srf";
// CRMIncident proxy object
Microsoft.CRM.Proxy.CRMIncident incident = new
Microsoft.CRM.Proxy.CRMIncident();
incident.Credentials = System.Net.CredentialCache.DefaultCredentials;
incident.Url = strDir + "CRMIncident.srf";
// CRMAccount proxy object
Microsoft.CRM.Proxy.CRMAccount account = new Microsoft.CRM.Proxy.CRMAccount
();
account.Credentials = System.Net.CredentialCache.DefaultCredentials;
account.Url = strDir + "CRMAccount.srf";
string strErrorMsg;
try
{
Microsoft.CRM.Proxy.CUserAuth userAuth = bizUser.WhoAmI();
// Set up the XML for a new account
// The required fields are name and ownerid
string strAccountXml = "<account>";
strAccountXml += "<name>Account Number 2</name>";
strAccountXml += "<accountnumber>A01923</accountnumber>";
strAccountXml += "<websiteurl>www.account1.com</websiteurl>";
strAccountXml += "<ownerid type=\"" +
Microsoft.CRM.Flags.ObjectType.otSystemUser.ToString() +"\">";
strAccountXml += userAuth.UserId + "</ownerid>";
strAccountXml += "</account>";
string strAccountId = account.Create(userAuth, strAccountXml);
// Set up the XML for a new incident
string strIncidentXml = "<incident>";
strIncidentXml += "<title>incident 1</title>";
strIncidentXml += "<accountid>" + strAccountId +"</accountid>";
strIncidentXml += "<ownerid type=\"" +
Microsoft.CRM.Flags.ObjectType.otSystemUser.ToString() +"\">";
strIncidentXml += userAuth.UserId + "</ownerid>";
strIncidentXml += "</incident>";
// Create an incident
string strIncidentId = incident.Create(userAuth, strIncidentXml);
// Now open the incident
incident.Open(userAuth, strIncidentId, -1);
}
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 );
}
I am trying to do some custom programming for CRM, but alas i am only a
classic asp programmer.
Can someone help me by translating this into asp.net in VB instead of C#, i
can then get on as i think i am okay with the rest only not too clever with
imports etc.
This is in the CRM SDK under CRMIncident.Open Method.
Thanks In Advance
[C#]
// server should be set with the name of the platform Web server
string server = "myservername";
// virtualDirectory should be set with the name of the Microsoft CRM
// Virtual Directory on the platform Web server
string virtualDirectory = "mscrmservices";
string strDir = "http://" + server + "/" + virtualDirectory + "/";
// BizUser proxy object
Microsoft.CRM.Proxy.BizUser bizUser = new Microsoft.CRM.Proxy.BizUser ();
bizUser.Credentials = System.Net.CredentialCache.DefaultCredentials;
bizUser.Url = strDir + "BizUser.srf";
// CRMIncident proxy object
Microsoft.CRM.Proxy.CRMIncident incident = new
Microsoft.CRM.Proxy.CRMIncident();
incident.Credentials = System.Net.CredentialCache.DefaultCredentials;
incident.Url = strDir + "CRMIncident.srf";
// CRMAccount proxy object
Microsoft.CRM.Proxy.CRMAccount account = new Microsoft.CRM.Proxy.CRMAccount
();
account.Credentials = System.Net.CredentialCache.DefaultCredentials;
account.Url = strDir + "CRMAccount.srf";
string strErrorMsg;
try
{
Microsoft.CRM.Proxy.CUserAuth userAuth = bizUser.WhoAmI();
// Set up the XML for a new account
// The required fields are name and ownerid
string strAccountXml = "<account>";
strAccountXml += "<name>Account Number 2</name>";
strAccountXml += "<accountnumber>A01923</accountnumber>";
strAccountXml += "<websiteurl>www.account1.com</websiteurl>";
strAccountXml += "<ownerid type=\"" +
Microsoft.CRM.Flags.ObjectType.otSystemUser.ToString() +"\">";
strAccountXml += userAuth.UserId + "</ownerid>";
strAccountXml += "</account>";
string strAccountId = account.Create(userAuth, strAccountXml);
// Set up the XML for a new incident
string strIncidentXml = "<incident>";
strIncidentXml += "<title>incident 1</title>";
strIncidentXml += "<accountid>" + strAccountId +"</accountid>";
strIncidentXml += "<ownerid type=\"" +
Microsoft.CRM.Flags.ObjectType.otSystemUser.ToString() +"\">";
strIncidentXml += userAuth.UserId + "</ownerid>";
strIncidentXml += "</incident>";
// Create an incident
string strIncidentId = incident.Create(userAuth, strIncidentXml);
// Now open the incident
incident.Open(userAuth, strIncidentId, -1);
}
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 );
}