Précédent   Forum des professionnels en informatique > Logiciels > Solutions d'entreprise > CRM > Microsoft Dynamics CRM
Microsoft Dynamics CRM Forum d'entraide Microsoft Dynamics CRM
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 03/05/2011, 16h48   #1
Membre régulier
 
Homme Jérôme Lambert
Développeur .NET
Inscription : décembre 2010
Messages : 99
Détails du profil
Informations personnelles :
Nom : Homme Jérôme Lambert
Âge : 27
Localisation : Belgique

Informations professionnelles :
Activité : Développeur .NET
Secteur : High Tech - Produits et services télécom et Internet

Informations forums :
Inscription : décembre 2010
Messages : 99
Points : 99
Points : 99
Par défaut CRM 2011 - connexion vbscript

Bonjour,
J'utilise un programme qui permet d'utiliser du vbscript lors d'événements (à la création d'un objet par exemple).
J'aimerais utiliser ce vbscript pour créer l'objet dans le CRM, mais je n'ai aucune idée de comment faire.
J'ai bien fait ce code en .Net (cs):
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
ClientCredentials credits = new ClientCredentials();
                credits.Windows.ClientCredential = new System.Net.NetworkCredential("user", "pass", "DOMAIN");
                using (_serviceProxy = new OrganizationServiceProxy(new Uri("http://crm2011/Domain/XRMServices/2011/Organization.svc"),
                                                                    null,
                                                                    credits,
                                                                    null))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

                    IOrganizationService service = (IOrganizationService)_serviceProxy;

                    // Display information about the logged on user.
                    Guid userid = ((WhoAmIResponse)service.Execute(new WhoAmIRequest())).UserId;

                    SystemUser systemUser = (SystemUser)service.Retrieve("systemuser", userid,
                        new ColumnSet(new string[] { "firstname", "lastname" }));
                    rtxConsole.Text = rtxConsole.Text + " Logged on user is " + systemUser.FirstName + " " + systemUser.LastName +".\n";

                    // Retrieve the version of Microsoft Dynamics CRM.
                    RetrieveVersionRequest versionRequest = new RetrieveVersionRequest();
                    RetrieveVersionResponse versionResponse =
                        (RetrieveVersionResponse)service.Execute(versionRequest);
                    rtxConsole.Text = rtxConsole.Text + " Microsoft Dynamics CRM version " + versionResponse.Version + ".\n";
                }
            }
                // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                rtxConsole.Text = rtxConsole.Text + "Erreur lors du démarrage du programme.\n";
                throw;
            }
Mais est-ce possible de le réécrire en vbscript?

Merci de votre aide,

Jérôme
Jerome2606 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/05/2011, 17h35   #2
Membre régulier
 
Homme Jérôme Lambert
Développeur .NET
Inscription : décembre 2010
Messages : 99
Détails du profil
Informations personnelles :
Nom : Homme Jérôme Lambert
Âge : 27
Localisation : Belgique

Informations professionnelles :
Activité : Développeur .NET
Secteur : High Tech - Produits et services télécom et Internet

Informations forums :
Inscription : décembre 2010
Messages : 99
Points : 99
Points : 99
Je vois sur un tuto, une manière de procéder avec du JavaScript:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// JScript source code

function LetterOnLoad() {

 

    var context = Xrm.Page.context;

    var serverUrl = context.getServerUrl();

    var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";

    var CRMObject = new Object();

 

    /////////////////////////////////////////////////////////////

    // Specify the ODATA entity collection

    var ODATA_EntityCollection = "/AccountSet";

 

    /////////////////////////////////////////////////////////////

    // Define attribute values for the CRM object you want created

    CRMObject.Name = "TEST";

    CRMObject.Telephone1 = "123";

    CRMObject.Fax = "456";

 

    //Parse the entity object into JSON

    var jsonEntity = window.JSON.stringify(CRMObject);

 

    //Asynchronous AJAX function to Create a CRM record using OData

    $.ajax({ type: "POST",

        contentType: "application/json; charset=utf-8",

        datatype: "json",

        url: serverUrl + ODATA_ENDPOINT + ODATA_EntityCollection,

        data: jsonEntity,

        beforeSend: function (XMLHttpRequest) {

            //Specifying this header ensures that the results will be returned as JSON.

            XMLHttpRequest.setRequestHeader("Accept", "application/json");

        },

        success: function (data, textStatus, XmlHttpRequest) {

            alert("success");

            var NewCRMRecordCreated = data["d"];

            alert("CRM GUID created: " + NewCRMRecordCreated.AccountId);

        },

        error: function (XMLHttpRequest, textStatus, errorThrown) {

            alert("failure");

        }

    });

}
Y a-t-il moyen d'utiliser tout ça en VBScript? J'avoue que je ne suis pas un pro des XMLHttpRequest et encore moins en VBScript (d'ailleurs je ne sais même pas si c'est possible).

Merci de l'aide que vous pourrez m'apporter,
Jérôme
Jerome2606 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 14h41   #3
Membre régulier
 
Homme Jérôme Lambert
Développeur .NET
Inscription : décembre 2010
Messages : 99
Détails du profil
Informations personnelles :
Nom : Homme Jérôme Lambert
Âge : 27
Localisation : Belgique

Informations professionnelles :
Activité : Développeur .NET
Secteur : High Tech - Produits et services télécom et Internet

Informations forums :
Inscription : décembre 2010
Messages : 99
Points : 99
Points : 99
J'avance petit à petit et j'ai besoin de votre aide, je me heurte à deux réponses Erreur 401 Unauthorized et 400 Bad request.

Voici mon code:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
xmlString = "<?xml version=""1.0"" encoding=""utf-8""?>" & _
			"<soap:envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">" & _
			"<soap:header>" & _
			"<CrmAuthenticationToken xmlns=""http://schemas.microsoft.com/crm/2007/WebServices"">" & _
			"<AuthenticationType xmlns=""http://schemas.microsoft.com/crm/2007/CoreTypes"">0</AuthenticationType>" & _
			"<OrganizationName xmlns=""http://schemas.microsoft.com/crm/2007/CoreTypes"">Domain</OrganizationName>" & _
			"</CrmAuthenticationToken>" & _
			"</soap:header>" & _
			"<soap:body>" & _
			"<Retrieve xmlns=""http://schemas.microsoft.com/crm/2007/WebServices"">" & _
			"<entityName>lead</entityName>" & _
			"<id>A9773AA7-4E72-E011-A880-005056A10010</id>" & _
			"<columnSet xmlns:q1=""http://schemas.microsoft.com/crm/2006/Query"" xsi:type=""q1:ColumnSet"">" & _
			"<q1:Attributes>" & _
			"<q1:Attribute>telephone1</q1:Attribute>" & _
			"</q1:Attributes>" & _
			"</columnSet>" & _
			"</Retrieve>" & _
			"</soap:body></soap:envelope>"
Set objXML2 = CreateObject("Msxml2.XMLHTTP.3.0")
serverUrl = "http://crm2011:5555/XRMServices/2011/OrganizationData.svc/LeadSet"
objXML2.Open "POST", serverUrl, False
objXML2.setRequestHeader "Accept", "application/xml, text/xml, */*"
objXML2.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
objXML2.setRequestHeader "SOAPAction", "http://schemas.microsoft.com/xrm/2011/Leads/Services/IOrganizationService/Execute"
objXML2.Send xmlString
Ma requête XML arrive bien mais on me renvois une réponse d'erreur avec une entête 401 et 400.
Quelqu'un a-t-il une idée?
Jerome2606 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/05/2011, 10h48   #4
Membre expérimenté
 
Avatar de KibitO
 
Chef de projet MOA
Inscription : septembre 2004
Messages : 537
Détails du profil
Informations personnelles :
Âge : 29
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Chef de projet MOA

Informations forums :
Inscription : septembre 2004
Messages : 537
Points : 528
Points : 528
Problème d'authentification peut-être..

Tu utilises FetchXmlBuilder pour tes requêtes SOAP ?
KibitO est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/05/2011, 17h00   #5
Membre régulier
 
Homme Jérôme Lambert
Développeur .NET
Inscription : décembre 2010
Messages : 99
Détails du profil
Informations personnelles :
Nom : Homme Jérôme Lambert
Âge : 27
Localisation : Belgique

Informations professionnelles :
Activité : Développeur .NET
Secteur : High Tech - Produits et services télécom et Internet

Informations forums :
Inscription : décembre 2010
Messages : 99
Points : 99
Points : 99
Non, c'est mon programme vbScript qui envoie la requête.
Je check les réponses avec Fiddler
Jerome2606 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/05/2011, 10h13   #6
Invité de passage
 
Inscription : juin 2007
Messages : 13
Détails du profil
Informations forums :
Inscription : juin 2007
Messages : 13
Points : 3
Points : 3
Par défaut Peut être un problème de jeton d'authentification

Salut,

J'ai le même problème, je n'ai pas encore réussi à le régler mais d'apres ce que j'ai compris, quand tu veux utiliser le webservice du CRM (à partir de la version 4) tu dois utiliser un jeton d'authentification "CrmAuthenticationToken".
C'est de là que doit venir ton erreur 401.

ICI tu as un exemple.
Jeremy9cinq est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 10h39.


 
 
 
 
Partenaires

Hébergement Web