Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Add your SAP Business ByDesign scripting language implementation for:
- Business Object: Opportunity
- Node: Root
- Action: checkIfClientIsOn_Boletagem
- Note:
- - To access the elements of the business object node,
- use path expressions, for example, this.<element name>.
- - To use code completion, press CTRL+J.
- */
- import ABSL;
- import AP.FO.BusinessPartner.Global;
- var request : Library::ClientGET_WSDL.SI_BUSCA_CLIENTE_SYNC_OUT.Request;
- var response : Library::ClientGET_WSDL.SI_BUSCA_CLIENTE_SYNC_OUT.Response;
- var scenario = "ClientGET_Scenario";
- if(this.ProspectParty.IsSet()) { //If there is a client associated to the opportunity
- var customer = Customer.Retrieve(this.ProspectParty.PartyUUID); //Get the client
- if(customer.IsSet()) {
- request.MT_BUSCA_CLIENTE_OUT.ID = customer.InternalID.RemoveLeadingZeros();
- response = Library::ClientGET_WSDL.SI_BUSCA_CLIENTE_SYNC_OUT(request, "", scenario);
- // error handling
- if (response.IsInitial()) {
- raise GenericMessage.Create("E", "Erro ao enviar o verificar Cliente no Boletagem");
- customer.CurrentCommon.wasSentToBoletagem = false;
- return;
- } else {
- // fault messages
- var faultItems = response.CommunicationFault.Item;
- var severity;
- if (faultItems.Count() > 0) {
- // do not send the complete error stack to the user. Assumption: last message is the most important on.
- raise GenericMessage.Create("E", "Erro: " + faultItems.GetLast().Note);
- customer.CurrentCommon.wasSentToBoletagem = false;
- return;
- }
- }
- if(response.MT_BUSCA_CLIENTE_OUT_RESPONSE.IsInitial()) {
- raise GenericMessage.Create("E", "Reposta vazia do Boletagem");
- customer.CurrentCommon.wasSentToBoletagem = false;
- return;
- }
- if(response.MT_BUSCA_CLIENTE_OUT_RESPONSE.LOG.IsInitial()) { //If find a client on the Boletagem, does not generate log.
- customer.CurrentCommon.wasSentToBoletagem = true;
- } else {
- customer.CurrentCommon.wasSentToBoletagem = false;
- }
- }
- else {
- raise GenericMessage.Create("E", "Oportunidade sem cliente válido");
- customer.CurrentCommon.wasSentToBoletagem = false;
- }
- }
- else {
- raise GenericMessage.Create("E", "Oportunidade sem cliente");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement