Sensor script

humblecommitted
Kilo Guru

Hello Community,

I have the following output that I am trying to capture the output for "Not After":

<?xml version="1.0" encoding="UTF-8"?><results probe_time="164"><result><output>Certificate:

      Data:

              Version: 3 (0x2)

              Serial Number: 132 (0x84)

              Signature Algorithm: sha1WithRSAEncryption

              Issuer: C=US, ST=Hawaii, O=State of Hawaii, OU=Department of Human Services, CN=inter-ca

              Validity

                      Not Before: Oct 17 02:25:35 2013 GMT

                      Not After : Oct 15 02:25:35 2023 GMT

I need help with the following script to parse the output:

new DiscoverySensor({

      process: function(result) {

              if (gs.nil(result.output))

                      return;

              this.parseOutput(result.output);

      },

      parseOutput: function(output) {

              var updated = false;

                              var lines = output.split(/\n/);

              for (var i = 0; i < lines.length; i++) {

                      var line = lines[i];

                      if (line == '')

                              continue;

                      var parts = line.split(" : ");

                      var name = parts[0].trim();

                      var value = parts[1].trim();

  if (name == "Not After")

  current.u_ssl_exp = value;

  }

          },

             

      type: "DiscoverySensor"

});

Any help would greatly be appreciated.

9 REPLIES 9

any updates on this?


Hi,



I have an external database. Everything(Incident) what i have done in my instance, it should get updated in that Database. I have created SOAP messages using WSDL and i am able to update it with Business rule.


But, I want it with Workflow. I have called the SOAP and filled all the Mandatory details like SOAP messages, Soap message function. And   i need bit clarity about Variables and Sensor script.


Can anyone please help me out on this??Is it same as Preview script Usage( from SOAP message) ? or do we need to write some other Script?


Hi Sashikanth,




I have an external database. Everything(Incident) what i have done in my instance, it should get updated in that Database. I have created SOAP messages using WSDL and i am able to update it with Business rule.


But, I want it with Workflow. I have called the SOAP and filled all the Mandatory details like SOAP messages, Soap message function. And   i need bit clarity about Variables and Sensor script.


Can anyone please help me out on this??Is it same as Preview script Usage( from SOAP message) ? or do we need to write some other Script?


rajeshraya
Giga Expert

I guess you are trying to update date time field. Try declaring your variable "value" in line 24 as a GlideDateTime type and then set value to it using the value you are getting after splitting output to that variable ("value"). Hope this helps.


Hi,


I have an external database. Everything(Incident) what i have done in my instance, it should get updated in that Database. I have created SOAP messages using WSDL and i am able to update it with Business rule.


But, I want it with Workflow. I have called the SOAP and filled all the Mandatory details like SOAP messages, Soap message function. And   i need bit clarity about Variables and Sensor script.


Can anyone please help me out on this??Is it same as Preview script Usage( from SOAP message) ? or do we need to write some other Script?