construct current date/time (using JavaScript) in method of a business object

Tagged:
  • Klaus79
    Participant
      5 years, 10 months ago #17973

      My BusinessObject has some parameters. For date and time I try to get the current ones with following little script before executing the corresponding connector.

       

      var date;
      var time
      date = input.requestDate;
      time = input.requestTime;
      if (date == “”)
      date = new Date().toISOString().slice(0, 10);
      if (time == “”)
      time = new Date().toISOString().slice(11, 21);
      var insertedID = Simplifier.Connector.QueueProcessor.saveRequest({
      “CustID”: input.CustID,
      “ReqDate”: date,
      “ReqTime”: time,
      “ReqType”: input.requestType,
      “requestor”: input.requestor,
      “status”: input.status
      })

      Connector respons with following message:

      {
      “message”: “Unexpected exception: com.itizzimo.appServer.connector.ConnectorType$PayloadValidationException: Invalid payload for connector type SQL: Parameter type of parameter ‘ReqDate’ could not be determined automatically because no JSON value was provided”,
      “success”: false
      }

      How can I construct current date, time, etc. in business objects?

      How can I debug my business object?

      jonas.rausch
      Participant
        Has successfully completed the online course Introduction
        Has successfully completed the online course Intermediate (200)
        Has successfully completed the online course Advanced (300)
      5 years, 10 months ago #17974
      Up
      1
      Down
      ::

      Hi Klaus,

      Tip:

      You can use moment.js in server- or clientside business object to get and format dates. Its very intuitive and gives you lots of options.

      To use it in a clientside businessobject, you need to add it as a managed library for the object, and it is always available in a server side business object.

       

      Now to the error you are seeing:

      Unfortunately, simplifier data type validation does not support js date objects at the moment and thus they wont be handed over to the connector.

      The error you are seeing means that the connector got an empty value for the “ReqDate” parameter.

      The recomended way to transmit date values it to transform them to String values.

       

      Debugging options for business objects vary between the 2 types:

      Client side business objects:

      You can simply use the js debugger; statement to create a breakpoint for your browser.

      Server side business objects:

      Debugging is a bit more complicated. You can create multiple outputs and and use the testing dialog to check the results step by step.

      Mathieu Roll
      Keymaster
        Has successfully completed the online course Introduction
        Has successfully completed the online course Intermediate (200)
        Has successfully completed the online course Advanced (300)
        Has successfully completed the online course Basics (100)
      5 years, 10 months ago #17976
      Up
      1
      Down
      ::

      Hello,

      i have a little complement for the debugging of server side bo’s.

      A better way is using the Simplifier.Log object because if the business object breaks with an error you will never get the output parameters.

      with the Simplifier.Log object he is logging into the Logs & Monitoring at the time you call it so if the Business Object breaks after your log statement the Log is already written to the Logs & Monitoring.

      There are 5 log levels.

      debug
      info
      warn
      error
      critical

      and you can use it like this.

      Simplifier.Log.debug(“message”, details)

      Note:
      The visibility of your log and loglevel depends on the server settings you have for log levels.

      In my case the Debug logs will not shown.

      Klaus79
      Participant
        5 years, 10 months ago #17978
        Up
        0
        Down
        ::

        Moment.js did it. Thx 🙂

      Viewing 4 posts - 1 through 4 (of 4 total)

      You must be logged in to reply to this topic.