Résumé
Manipulation de l'entité Deal (Affaires) en lecture/écriture/suppression via un objet métier depuis une application externe.
Remarque
A partir de la Summer'22, le webhook Deal a été scindé en deux afin de gérer les opportunités séparément. Il faudra donc à présent utiliser le nouveau webhook Opportunity pour cette partie.
Tables
Les tables utilisées sont :
sw_data_deal : Table des opportunités/affaires
Les tables liées sont :
sw_data_dealelement : Table des éléments d'affaire
Critères d'activation
WHK_Deal est défini dans la gestion des webhooks du studio.
Règles métier
verb: PUT
La date de création est mise par défaut à la date du jour (creationDate) si non fournie lors d'une création
Le statut est mis par défaut à 'Brouillon' (generictype_ID_status = DRAFTING) si non fourni lors d'une création
Fonctionnement
settings parameters
"settings": { "getPartners": "1" // pour le verb GET et LIST permet de retourner les informations des partenaires de l'affaire }
verb: GET
resultType: simple
"deal":{ "codedeal": "AFR000011", "customer_ID": "C0000001", "label": "Vitrine de magasin", "creationDate": "2021-12-01 00:00:00" "generictype_ID_dealType": "Type affaire 1", "generictype_ID_status": "STARTED", "dealNumber": "AFR000011" }
verb: GET
resultType: extended
"deal":{ "codedeal": "AFR000011", "customer_ID": "C0000001", "label": "Vitrine de magasin", "creationDate": "2021-12-01 00:00:00", "generictype_ID_dealType": "Type affaire 1", "generictype_ID_status": "STARTED", "dealNumber": "AFR000011", "description": "", "closingDate": "", "amount": "300", "probability": "55", "customer_ID_introducer": "", "baseuser_ID": "MOREL", "amount2": "", "realClosingDate": "", "dealstep_ID_current": "", "deal_ID_origin": "", "manualProbability": "0", "marketinglead_ID_origin": "", "customercontact_ID": "C0000001-DJ" }
verb: GET
resultType: extendedRelated
en complément du résultat pour resultType: extended on aura le détail pour les tables generictype_deal_type, customer, customercontact, baseuser et generictype_status
"related":[ { "generictype_dealType":{ "codegenerictype": "DEAL_DEALTYPE-AFR", "label": "Type affaire 1", "originalCode": "AFR", "dataType": "DEAL_DEALTYPE", "description": "", "translationKey": "", "generictype_ID_parent": "Deal", "tag":"", "orderNumber":"" }, "generictype_status": { "codegenerictype": "DEAL_STATUS-3", "label": "Démarré", "originalCode": "3", "dataType": "DEAL_STATUS_V2", "description": "", "translationKey": "GenType_DEAL_STATUS_STARTED", "generictype_ID_parent": "", "tag": "STARTED", "orderNumber": "" }, "customer":{ "codecustomer": "C0000001", "name": "ENTREPRISE DIJON GUICHARD", "baseuser_ID": "", "address1" :"33 Avenue du Drapeau", "address2": "", "address3": "", "postalCode": "21000", "city": "DIJON", "phoneNumber": "03 90 11 22 33", "faxNumber": "03 90 11 22 44", "mobilePhoneNumber": "06 90 11 22 33", "email": "contact@guichard.com", "deliveryDays": "1A;1B;2A;2B;3A;3B;4A;4B;5A;5B", "openingDays": "1A;1B;2A;2B;3A;3B;4A;4B;5A;5B", "siretNumber":" ", "vatIntra": "", "apeCode": "516K", "comment": "", "blocked": "0", "blockedComment": "", "message": "", "vacationStart": "", "vacationEnd": "", "gpsLongitude": "5.04372", "gpsLatitude": "47.33222", "accountNumber": "C0000001", "contactName": "", "currency_ID": "", "authorizedCredit": "0", "risk": "1", "underSurveillance": "", "workforce": "25", "customer_ID_paying": "", "pricecategory_ID": "", "discountRate": "0", "website": "https://www.guichard.com", "legalStatus": "Société Anonyme avec Directoire", "generictype_ID_brand": "", "generictype_ID_deliveryMode": "", "generictype_ID_paymentMean": "", "generictype_ID_country": "", "generictype_ID_province": "", "generictype_ID_customerType": "CTC", "generictype_ID_customerFamily": "", "confirmationEmail": "contact@guichard.com", "confirmationFax": "03 90 11 22 44", "generictype_ID_taxCode": "", "productdepot_ID": "", "generictype_ID_accountingCategory": "", "generictype_ID_customerPotential": "B", "generictype_ID_civility": "", "skype": "contact@guichard.com", "generictype_ID_role": "", "unused": "0", "customergroup_ID": "", "generictype_ID_referencing": "2", "generictype_ID_distribution": "SELF", "generictype_ID_market": "BIG", "area": "", "baseculture_ID": "FR-FR", "baseuser_ID_favoriteTechnician": "TECH-01", "branchoffice_ID": "SXB", "emailFormat": "", "isIndividual": "0", "facebook": "https://www.facebook.com/guichard/", "twitter": "https://twitter.com/guichard", "youtube": "https://www.youtube.com/watch?v=6jGbnEwQJ54", "linkedin": "https://www.linkedin.com/company/guichard", "activity": "" }, "customercontact":{ "codecustomercontact": "C0000001-DJ", "customer_ID": "C0000001", "lastName": "DENEIR", "firstName": "Jacques", "generictype_ID_civility": "Monsieur", "address1": "1b rue Darwin", "address2": "", "address3": "", "postalCode": "21000", "city": "DIJON", "phoneNumber": "05 55 79 56 92", "faxNumber": "05 55 79 56 11", "mobilePhoneNumber": "06 07 08 09 10", "email": "jdeneir@nebout.div", "gpsLongitude": "5.0384", "gpsLatitude": "47.33073", "description": "Acheteur direct", "generictype_ID_position": "Direction", "birthday": "1980-09-18 00:00:00", "generictype_ID_country": "FR", "generictype_ID_province": "", "mainContact": "0", "generictype_ID_service": "Direction", "skype": "", "baseculture_ID": "", "bouncedEmailDetected": "", "closedDate": "", "twitter": "", "linkedin": "" }, "baseuser":{ "codebaseuser":"25", "lastName":"MOREL", "firstName":"Vincent", "initials":"MV", "baseusertree_ID":"Région 2", "productdepot_ID":"Dépôt Vincent MOREL", "productdepot_ID_current":"", "email":"vincent@morel.com", "phoneNumber":"", "faxNumber":"", "address1":"", "address2":"", "postalCode":"", "city":"", "position":"Représentant", "department":"Commercial", "structureNav":"1", "supervisor":"0", "useMileageRate":"", "account":"", "analyticSection":"", "lastGPSDate":"", "gpsLongitude":"", "gpsLatitude":"", "gpsPrecision":"", "gpsUpdateDate":"", "gpsManual":"", "generictype_ID_country":"", "generictype_ID_province":"", "baseculture_ID":"", "branchoffice_ID":"", "resourcetype_ID":"", "teamtype_ID":"" } }]
verb: PUT
{ "deal": { "codedeal": "AFR000011", /* Code globalement unique de l'affaire (Varchar (255))*/ "customer_ID": "C0000001", /* Code client (ForeignKey () - sw_data_customer.codecustomer)*/ "label": "Vitrine de magasin", /* Libellé (Varchar (255))*/ "generictype_ID_dealType": "DEAL_DEALTYPE-AFR", /* Code type d'affaire (ForeignKey () - sw_data_generictype.codegenerictype avec datatype = DEAL_DEALTYPE) et generictype_ID_parent = DEAL*/ "dealNumber": "AFR000011", /* N° d'affaire (Varchar (64))*/ "description": "", Description (Text (65535))*/ "creationDate" : "2021-12-01", /* Date de création (DateTime ())*/ "closingDate": "", /* Date de fin (DateTime ())*/ "amount": "300", /* Montant (Double ())*/ "probability": "55", /* Probabilité (en %) (Int ())*/ "customer_ID_introducer": "", /* Code client apporteur d'affaire (ForeignKey () - sw_data_customer.codecustomer) "baseuser_ID": "25", /* Code responsable (ForeignKey () - sw_data_baseuser.codebaseuser)*/ "amount2": "", /* Montant 2 (Double ())*/ "generictype_ID_status": "DEAL_STATUS-3", /* Statut (ForeignKey () - sw_data_generictype.codegenerictype avec datatype = DEAL_STATUS_V2)*/ "realClosingDate": "", /* Date de fin réelle (DateTime ())*/ "dealstep_ID_current": "", /* Code étape actuelle (ForeignKey () - sw_data_dealstep.codedealstep)*/ "deal_ID_origin": "", /* Code opportunité d'origine (ForeignKey () - sw_data_deal.codedeal)*/ "manualProbability": "0", /* Probabilité manuelle (Valeurs possibles : 0,1) (Bool ())*/ "marketinglead_ID_origin": "", /* Code lead marketing d'origine (ForeignKey () - sw_data_marketinglead.codemarketinglead)*/ "customercontact_ID": "C0000001-DJ", /* Code contact client (ForeignKey () - sw_data_customercontact.codecustomercontact)*/ "internalcodedeal": null /* Code deal original de weavy s'il y a eu transcodage (Varchar (255)) */ /* Optionnel : pour mettre à jour les champs dynamiques selon paramétrage */ /* Exemple 1 : */ "dynamicfields": [{ "fieldname": "aff10", "fieldvalue": "100000" }, { "fieldname": "aff30", "fieldvalue": "Jean-René Abraham" }, { ... }] /* Exemple 2 : */ /* A partir de la version SUMMER'21, le mappage direct des champs dynamiques est possible en utilisant le nom du champ en bdd */ "v_aff10": "100000", "v_aff30": "Jean-René Abraham", ... }, "dealelement": [ { "codedealelement": "AFR000011-0-1", /* Code globalement unique de l'élément d'affaire (Varchar (255))*/ "deal_ID": "AFR000011", /* Code affaire. Reprendre le code affaire du bloc json "deal" (ForeignKey () - sw_data_deal.codedeal)*/ "label" : "Elément 1", /* Libellé (Varchar (255))*/ "DataOrder": "10", /* Ordre d'affichage (Int ())*/ "originalCode": "1", /* Code de l'élément d'affaire à afficher (Varchar (255))*/ "dealelementstructure_ID": "", /* Code structure (ForeignKey () - sw_data_dealelementstructure.codedealelementstructure)*/ "dealelement_ID_parent": "" /* Code élément d'affaire parent (nécessite que le parent a été créée avant celui-ci) (ForeignKey () - sw_data_dealelement.codedealelement)*/ }, { "codedealelement": "AFR000011-0-1.1", /* Code globalement unique de l'élément d'affaire (Varchar (255))*/ "deal_ID": "AFR000011", /* Code affaire. Reprendre le code affaire du bloc json "deal" (ForeignKey () - sw_data_deal.codedeal)*/ "label" : "Elément 1.1", /* Libellé (Varchar (255))*/ "DataOrder": "11", /* Ordre d'affichage (Int ())*/ "originalCode": "1.1", /* Code de l'élément d'affaire à afficher (Varchar (255))*/ "dealelementstructure_ID": "", /* Code structure (ForeignKey () - sw_data_dealelementstructure.codedealelementstructure)*/ "dealelement_ID_parent": "AFR000011-0-1" /* Code élément d'affaire parent (nécessite que le parent a été créée avant celui-ci) (ForeignKey () - sw_data_dealelement.codedealelement)*/ }, { "codedealelement": "AFR000011-0-2", /* Code globalement unique de l'élément d'affaire (Varchar (255))*/ "deal_ID": "PJ000011", /* Code affaire. Reprendre le code affaire du bloc json "deal" (ForeignKey () - sw_data_deal.codedeal)*/ "label" : "Elément 2", /* Libellé (Varchar (255))*/ "DataOrder": "20", /* Ordre d'affichage (Int ())*/ "originalCode": "2", /* Code de l'élément d'affaire à afficher (Varchar (255))*/ "dealelementstructure_ID": "", /* Code structure (ForeignKey () - sw_data_dealelementstructure.codedealelementstructure)*/ "dealelement_ID_parent": "" /* Code élément d'affaire parent (nécessite que le parent a été créée avant celui-ci) (ForeignKey () - sw_data_dealelement.codedealelement)*/ }] }
verb: LIST
resultType: simple, extended reprendre les définitions du GET
"filters:" { "codeDeal": "value", filter is equal "dealNumber": "value", filter is equal "label": "value", filter is contains "creationDate": "value", filter is greater or equal to "creationDateBetween": "value1|value2", filter is between value1 and value2 "codeCustomer": "value", filter is equal "dealType": "value", filter is equal "codeStatus": "value" filter is equal }, "orderBy": "value"
Valeurs possibles pour le tri "orderBy" :
dealNumberAsc : par n° d'affaire ascendant
labelAsc : par intitulé ascendant
creationDateAsc : par date de création ascendant
creationDateDesc : par date de création descendant
verb: DELETE
Une suppression d'une affaire (sw_data_deal) va supprimer en cascade les éléments dans la table liée sw_data_dealelement.