Skip to main content
1-Visitor
February 14, 2019
Solved

How to call one service in another service using java script?

  • February 14, 2019
  • 5 replies
  • 4137 views

Hi,

 I have two services. One contains all data(One of the columns is a number which is got from SQL query) and another service which is used to convert the number to DateTime(Javascript).  Now i would like to modify all numbers to DateTime using another service. Is it possible? Please, anyone, help me out on this.

 

Regards,

Surekha N.

Best answer by zyuan1

// use first service result: DATETIME as input to second service
var input = me.GetDateTimePropertyValue({
propertyName: me.lastConnection/* STRING */
});
// result: INFOTABLE dataShape: "DateTimeValueStream"
var result = me.QueryDateTimePropertyHistory({
oldestFirst: undefined /* BOOLEAN */,
maxItems: undefined /* NUMBER */,
propertyName: undefined /* STRING */,
endDate: undefined /* DATETIME */,
query: undefined /* QUERY */,
startDate: input /* DATETIME */
});

5 replies

5-Regular Member
February 14, 2019

You can only return one result in the script but you can call several services inside. just use add service - entities to find the service you want.

 

var params = {
propertyName: undefined /* STRING */,
value: undefined /* DATETIME */,
timestamp: undefined /* DATETIME */
};

// no return
Things["azureRhel-AnalyticsServer"].AddDateTimeValueStreamEntry(params);


var params1 = {
property: undefined /* STRING */,
message: undefined /* STRING */
};

// no return
Things["azureRhel-AnalyticsServer"].AcknowledgeAlert(params1);

 

These 2 services won't interfere with each other, so they can run in order.

Surekha1-VisitorAuthor
1-Visitor
February 14, 2019

Hi @zyuan1 ,

     I want to pass one service data to another service here.

 

Regards,

Surekha N.

zyuan15-Regular MemberAnswer
5-Regular Member
February 15, 2019

// use first service result: DATETIME as input to second service
var input = me.GetDateTimePropertyValue({
propertyName: me.lastConnection/* STRING */
});
// result: INFOTABLE dataShape: "DateTimeValueStream"
var result = me.QueryDateTimePropertyHistory({
oldestFirst: undefined /* BOOLEAN */,
maxItems: undefined /* NUMBER */,
propertyName: undefined /* STRING */,
endDate: undefined /* DATETIME */,
query: undefined /* QUERY */,
startDate: input /* DATETIME */
});