lorduakiti

Fluig Atualiza Forms

Apr 4th, 2019
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function RequisicaoXML(url, xml){
  2.    
  3.     var xhr = new XMLHttpRequest();
  4.     xhr.onreadystatechange = function() {
  5.         if (this.readyState == 4 && this.status == 200) {
  6.             var response = (this.responseText);  
  7.             console.log(response);    
  8.         }
  9.     };
  10.     xhr.open("POST", url, false);
  11.     xhr.setRequestHeader('Content-Type', 'application/json');
  12.     xhr.send(xml);
  13. }
  14.  
  15.  
  16. function AtualizarFormulario(processo, campo, valor) {
  17.     console.log('%c -> AtualizarFormulario: [' +  processo + '] ' + campo + '=(' + valor + ')', 'color:orange');
  18.  
  19.     var url = parent.WCMAPI.serverURL + "/webdesk/ECMCardService?wsdl";
  20.     var cardId = FormularioProcesso(processo);
  21.  
  22.     var xmlItem = "<item>";
  23.     xmlItem += "    <field>" + campo + "</field>";
  24.     xmlItem += "    <value>" + valor + "</value>";
  25.     xmlItem += "</item>";
  26.  
  27.     var xml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.dm.ecm.technology.totvs.com/">'
  28.         +'<soapenv:Header/>'
  29.         +'<soapenv:Body>'
  30.             +'<ws:updateCardData>'
  31.             +'<companyId>' + top.WCMAPI.organizationId + '</companyId>'
  32.             +'<username></username>'
  33.             +'<password></password>'
  34.             +'<cardId>' + cardId + '</cardId>'
  35.             +'<cardData>'
  36.                 + xmlItem
  37.             +'</cardData>'
  38.             +'</ws:updateCardData>'
  39.         +'</soapenv:Body>'
  40.         +'</soapenv:Envelope>';
  41.    
  42.     RequisicaoXML(url, xml);
  43.    
  44. }
Advertisement
Add Comment
Please, Sign In to add comment