Advertisement
Zavaski

Untitled

Sep 24th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. import ABSL;
  2. import AP.FO.BusinessPartner.Global;
  3. import AP.CRM.Global;
  4. import AP.FO.Address.Global;
  5.  
  6. if(!this.user_id.IsInitial()){
  7. //proucurar customer
  8. var customerQuery = Customer.QueryByIdentification;
  9. var customerSelectionParams = customerQuery.CreateSelectionParams();
  10. customerSelectionParams.Add(customerQuery.IDScupClient_EA8AE8AUBVHCSXVYS0FJ1R3ON, "I", "EQ", this.user_id);
  11. var customerResultList = customerQuery.ExecuteDataOnly(customerSelectionParams);
  12. var customerID;
  13. //nao achou customer
  14. if(customerResultList.Count() == 0){
  15. //pegar customer por request
  16. this.integrationScupCustomer();
  17. //verificar se tem o user associado
  18. if(this.ToUser.IsSet()){
  19. //verificar se tem email / CPF
  20. if(!this.ToUser.email.IsInitial()){
  21. var elCustomerRoot : elementsof Customer;
  22. var newCustomer;
  23. //var elCustomerPerson : elementsof Customer.Common.;
  24. elCustomerRoot.CategoryCode = "1";
  25. newCustomer = Customer.Create(elCustomerRoot);
  26. if(newCustomer.IsSet()){
  27. var userScup = this.ToUser;
  28. //criar customer
  29. //var customer = Customer.Retrieve(this.user_id);
  30. //preencher nome
  31. var nome = "";
  32. if(!userScup.facebook_name.IsInitial()){
  33. nome = userScup.facebook_name;
  34. }
  35. else if(!userScup.foursquare_name.IsInitial()){
  36. nome = userScup.foursquare_name;
  37. }
  38. else if(userScup.googleplus_name.IsInitial()){
  39. nome = userScup.googleplus_name;
  40. }
  41. else if(userScup.instagram_name.IsInitial()){
  42. nome = userScup.instagram_name;
  43. }
  44. else if(userScup.twitter_name.IsInitial()){
  45. nome = userScup.twitter_name;
  46. }
  47.  
  48. if(!nome.IsInitial()){
  49. var fim1oNome = nome.Find(" ");
  50. if (fim1oNome >= 0) {
  51. var primeiroNome = nome.Substring(0, fim1oNome).Trim();
  52. var sobreNome = nome.Substring(fim1oNome).Trim();
  53. newCustomer.CurrentCommon.Person.Name.GivenName = primeiroNome;
  54. newCustomer.CurrentCommon.Person.Name.FamilyName = sobreNome;
  55. }
  56. else{
  57. newCustomer.CurrentCommon.Person.Name.GivenName = nome;
  58. }
  59. }
  60. //preencher email
  61. newCustomer.CurrentDefaultAddressInformation.Address.DefaultEMail.URI.content = userScup.email;
  62. var teste = "oi";
  63. //preencher CPF
  64. //customer.CurrentCommon.CPF = userScup.document;
  65. }
  66. }
  67.  
  68. }
  69. }
  70. //achou customer
  71. else{
  72. customerID = customerResultList.GetFirst().InternalID;
  73. }
  74.  
  75. //cria ticket
  76. var serviceRequest = ServiceRequest.Create();
  77. serviceRequest.Name.content = "Resposta negativa na pesquisa de satisfação";
  78. //serviceRequest.BuyerParty.PartyKey.PartyID.content = "1000000";
  79. serviceRequest.BuyerParty.PartyKey.PartyID.content = customerID;
  80.  
  81. var description2 = serviceRequest.IncidentDescriptionTextCollectionText.Create();
  82. var text = description2.TextContent.Create();
  83. text.FormattedText.content = "Cliente respondeu: \"Ruim\" na pergunta: \"";
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement