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.Ope n Method.
Thanks In Advance
[C#]
// server should be set with the name of the platform Web server
string server = "myserverna me";
// virtualDirector y should be set with the name of the Microsoft CRM
// Virtual Directory on the platform Web server
string virtualDirector y = "mscrmservices" ;
string strDir = "http://" + server + "/" + virtualDirector y + "/";
// BizUser proxy object
Microsoft.CRM.P roxy.BizUser bizUser = new Microsoft.CRM.P roxy.BizUser ();
bizUser.Credent ials = System.Net.Cred entialCache.Def aultCredentials ;
bizUser.Url = strDir + "BizUser.sr f";
// CRMIncident proxy object
Microsoft.CRM.P roxy.CRMInciden t incident = new
Microsoft.CRM.P roxy.CRMInciden t();
incident.Creden tials = System.Net.Cred entialCache.Def aultCredentials ;
incident.Url = strDir + "CRMIncident.sr f";
// CRMAccount proxy object
Microsoft.CRM.P roxy.CRMAccount account = new Microsoft.CRM.P roxy.CRMAccount
();
account.Credent ials = System.Net.Cred entialCache.Def aultCredentials ;
account.Url = strDir + "CRMAccount.srf ";
string strErrorMsg;
try
{
Microsoft.CRM.P roxy.CUserAuth userAuth = bizUser.WhoAmI( );
// Set up the XML for a new account
// The required fields are name and ownerid
string strAccountXml = "<account>" ;
strAccountXml += "<name>Acco unt Number 2</name>";
strAccountXml += "<accountnumber >A01923</accountnumber>" ;
strAccountXml += "<websiteurl>ww w.account1.com</websiteurl>";
strAccountXml += "<ownerid type=\"" +
Microsoft.CRM.F lags.ObjectType .otSystemUser.T oString() +"\">";
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>inciden t 1</title>";
strIncidentXml += "<accountid >" + strAccountId +"</accountid>";
strIncidentXml += "<ownerid type=\"" +
Microsoft.CRM.F lags.ObjectType .otSystemUser.T oString() +"\">";
strIncidentXml += userAuth.UserId + "</ownerid>";
strIncidentXml += "</incident>";
// Create an incident
string strIncidentId = incident.Create (userAuth, strIncidentXml) ;
// Now open the incident
incident.Open(u serAuth, strIncidentId, -1);
}
catch (System.Web.Ser vices.Protocols .SoapException err)
{
// Process the platform error here
strErrorMsg = ("ErrorMessa ge: " + err.Message + " " + err.Detail.Oute rXml
+ " Source: " + err.Source );
}
catch (Exception err)
{
// Process other errors here
strErrorMsg = ("ErrorMessa ge: " + 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.Ope n Method.
Thanks In Advance
[C#]
// server should be set with the name of the platform Web server
string server = "myserverna me";
// virtualDirector y should be set with the name of the Microsoft CRM
// Virtual Directory on the platform Web server
string virtualDirector y = "mscrmservices" ;
string strDir = "http://" + server + "/" + virtualDirector y + "/";
// BizUser proxy object
Microsoft.CRM.P roxy.BizUser bizUser = new Microsoft.CRM.P roxy.BizUser ();
bizUser.Credent ials = System.Net.Cred entialCache.Def aultCredentials ;
bizUser.Url = strDir + "BizUser.sr f";
// CRMIncident proxy object
Microsoft.CRM.P roxy.CRMInciden t incident = new
Microsoft.CRM.P roxy.CRMInciden t();
incident.Creden tials = System.Net.Cred entialCache.Def aultCredentials ;
incident.Url = strDir + "CRMIncident.sr f";
// CRMAccount proxy object
Microsoft.CRM.P roxy.CRMAccount account = new Microsoft.CRM.P roxy.CRMAccount
();
account.Credent ials = System.Net.Cred entialCache.Def aultCredentials ;
account.Url = strDir + "CRMAccount.srf ";
string strErrorMsg;
try
{
Microsoft.CRM.P roxy.CUserAuth userAuth = bizUser.WhoAmI( );
// Set up the XML for a new account
// The required fields are name and ownerid
string strAccountXml = "<account>" ;
strAccountXml += "<name>Acco unt Number 2</name>";
strAccountXml += "<accountnumber >A01923</accountnumber>" ;
strAccountXml += "<websiteurl>ww w.account1.com</websiteurl>";
strAccountXml += "<ownerid type=\"" +
Microsoft.CRM.F lags.ObjectType .otSystemUser.T oString() +"\">";
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>inciden t 1</title>";
strIncidentXml += "<accountid >" + strAccountId +"</accountid>";
strIncidentXml += "<ownerid type=\"" +
Microsoft.CRM.F lags.ObjectType .otSystemUser.T oString() +"\">";
strIncidentXml += userAuth.UserId + "</ownerid>";
strIncidentXml += "</incident>";
// Create an incident
string strIncidentId = incident.Create (userAuth, strIncidentXml) ;
// Now open the incident
incident.Open(u serAuth, strIncidentId, -1);
}
catch (System.Web.Ser vices.Protocols .SoapException err)
{
// Process the platform error here
strErrorMsg = ("ErrorMessa ge: " + err.Message + " " + err.Detail.Oute rXml
+ " Source: " + err.Source );
}
catch (Exception err)
{
// Process other errors here
strErrorMsg = ("ErrorMessa ge: " + err.Message );
}
Comment