Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ABSL;
- import AP.FO.BusinessPartner.Global;
- import AP.CRM.Global;
- import AP.FO.Address.Global;
- if(!this.user_id.IsInitial()){
- //proucurar customer
- var customerQuery = Customer.QueryByIdentification;
- var customerSelectionParams = customerQuery.CreateSelectionParams();
- customerSelectionParams.Add(customerQuery.IDScupClient_EA8AE8AUBVHCSXVYS0FJ1R3ON, "I", "EQ", this.user_id);
- var customerResultList = customerQuery.ExecuteDataOnly(customerSelectionParams);
- var customerID;
- //nao achou customer
- if(customerResultList.Count() == 0){
- //pegar customer por request
- this.integrationScupCustomer();
- //verificar se tem o user associado
- if(this.ToUser.IsSet()){
- //verificar se tem email / CPF
- if(!this.ToUser.email.IsInitial()){
- var elCustomerRoot : elementsof Customer;
- var newCustomer;
- //var elCustomerPerson : elementsof Customer.Common.;
- elCustomerRoot.CategoryCode = "1";
- newCustomer = Customer.Create(elCustomerRoot);
- if(newCustomer.IsSet()){
- var userScup = this.ToUser;
- //criar customer
- //var customer = Customer.Retrieve(this.user_id);
- //preencher nome
- var nome = "";
- if(!userScup.facebook_name.IsInitial()){
- nome = userScup.facebook_name;
- }
- else if(!userScup.foursquare_name.IsInitial()){
- nome = userScup.foursquare_name;
- }
- else if(userScup.googleplus_name.IsInitial()){
- nome = userScup.googleplus_name;
- }
- else if(userScup.instagram_name.IsInitial()){
- nome = userScup.instagram_name;
- }
- else if(userScup.twitter_name.IsInitial()){
- nome = userScup.twitter_name;
- }
- if(!nome.IsInitial()){
- var fim1oNome = nome.Find(" ");
- if (fim1oNome >= 0) {
- var primeiroNome = nome.Substring(0, fim1oNome).Trim();
- var sobreNome = nome.Substring(fim1oNome).Trim();
- newCustomer.CurrentCommon.Person.Name.GivenName = primeiroNome;
- newCustomer.CurrentCommon.Person.Name.FamilyName = sobreNome;
- }
- else{
- newCustomer.CurrentCommon.Person.Name.GivenName = nome;
- }
- }
- //preencher email
- newCustomer.CurrentDefaultAddressInformation.Address.DefaultEMail.URI.content = userScup.email;
- var teste = "oi";
- //preencher CPF
- //customer.CurrentCommon.CPF = userScup.document;
- }
- }
- }
- }
- //achou customer
- else{
- customerID = customerResultList.GetFirst().InternalID;
- }
- //cria ticket
- var serviceRequest = ServiceRequest.Create();
- serviceRequest.Name.content = "Resposta negativa na pesquisa de satisfação";
- //serviceRequest.BuyerParty.PartyKey.PartyID.content = "1000000";
- serviceRequest.BuyerParty.PartyKey.PartyID.content = customerID;
- var description2 = serviceRequest.IncidentDescriptionTextCollectionText.Create();
- var text = description2.TextContent.Create();
- text.FormattedText.content = "Cliente respondeu: \"Ruim\" na pergunta: \"";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement